asp.net - 无法获取 SPAppWebUrl - SharePoint 2013

标签 asp.net sharepoint token

我正在为 Sharepoint 2013 开发一个自动托管的 asp.net 应用程序。我必须为我的请求使用 SPAppWebUrl token 值。所以我尝试了这个:

  • AppManifest.xml : <StartPage>~remoteAppUrl/Pages/Index.aspx?{StandardTokens}</StartPage>
  • javascript:var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
  • C# 代码隐藏: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/

    相关文章:

    javascript - Sharepoint JavaScript

    c - 使用 strtok 的奇怪标记结果

    sharepoint - 如何最好地将SharePoint多用户字段字符串转换为SPUsers数组?

    jQuery 追加在 Internet Explorer 中不起作用

    javascript - Google 热图仅显示一处

    c# - VS Code 是否支持 ASPX 文件中的服务器端代码?

    c++ - 在 C++ 中抽象文本解析的库

    ruby-on-rails - 将 devise_token_auth 与表单例份验证一起使用

    c# - 什么是 ASP.NET Core MVC 等同于 Request.RequestURI?

    asp.net - 双列表拖放控件