我正在为 Sharepoint 2013 开发一个自动托管的 asp.net 应用程序。我必须为我的请求使用 SPAppWebUrl token 值。所以我尝试了这个:
<StartPage>~remoteAppUrl/Pages/Index.aspx?{StandardTokens}</StartPage>
var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
Application["SPAppWebUrl"] = Request.QueryString["SPAppWebUrl"];
没有任何效果。 Sharepoint 仅发送 SPHostUrl、SPLanguage、SPClientTag 和 SPProductNumber 的值。我读了topics about tokens并注意到这一点:
If there is no app web, the portion &SPAppWebUrl={AppWebUrl} is not present.
但我不明白我怎么不能有一个应用程序网络......
如果有人可以帮忙请。谢谢。
最佳答案
我在使用 Provider Hosted 时遇到了类似的问题。我的 App Web 没有出现,因为我尝试使用不起作用的证书(通配符)。使用自签名证书第二次完成证书设置 - 然后设置一个虚拟列表,当我查看时:
string spAppUrl = Request["SPAppWebUrl"];
我正在恢复正确的值(value)。然后我使用 URL 通过以下方式获取您的应用程序网络:
System.Security.Principal.WindowsIdentity currentUser = Request.LogonUserIdentity;
using (var appContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(appUri, currentUser))
{
if (appContext != null)
{
Web appWeb = appContext.Web;
appContext.Load(appWeb, w => w.Title);
appContext.ExecuteQuery();
string title = appWeb.Title;
ViewBag.SiteTitle = title;
}
}
关于asp.net - 无法获取 SPAppWebUrl - SharePoint 2013,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18334525/