【问题标题】:How to access sharepoint data to asp.net?如何访问asp.net的sharepoint数据?
【发布时间】:2018-04-23 14:15:40
【问题描述】:

我目前正在使用 asp.net 开发一个网站,该网站应该连接到共享点并访问其数据和文件,现在我正在尝试 CSOM(客户端对象模型)。但是当我尝试访问该 URL 时出现错误。

System.Net.WebException: '远程服务器返回错误:(403) Forbidden。'

这是我的代码:

SPClient.ClientContext ctx = new SPClient.ClientContext("Site URL");
        SPClient.Web myWeb = ctx.Web;
        ctx.Load(myWeb, w => w.Title);
        ctx.ExecuteQuery();
        Response.Write(myWeb.Title);

【问题讨论】:

    标签: asp.net sharepoint csom


    【解决方案1】:

    您尚未为请求设置凭据。

    SharePoint 本地部署:

    context.Credentials = new NetworkCredential("user", "password", "domain");
    

    SharePoint 在线:

        SecureString passWord = new SecureString();
        foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c);
        context.Credentials = new SharePointOnlineCredentials(username, passWord);
    

    【讨论】:

      猜你喜欢
      • 2010-10-18
      • 1970-01-01
      • 2012-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-25
      • 1970-01-01
      相关资源
      最近更新 更多