【问题标题】:401 unauthorized exception while reading data from the document library SharePoint 2010从文档库 SharePoint 2010 读取数据时出现 401 未经授权的异常
【发布时间】:2011-11-25 03:52:49
【问题描述】:

我们开发了一个 WebPart 来读取 SiteCollection 中文档库中文件的内容。我使用以下代码读取内容。

 WebClient wc = new WebClient();
 wc.Credentials = CredentialCache.DefaultNetworkCredentials;
 string documenturl = siteurl+"/" + file.Url.ToString();
 content = wc.DownloadData(documenturl);//documenturl is the file path of the document

但是,我得到了以下错误 401 unathorized exception

System.Net.WebException: The remote server returned an error:(401) Unauthorized. at System.Net.WebClient.DownloadDataInternal(Uri address,WebRequest& request) at System.Net.WebClient.DownloadData(Uri address)

为了您的信息,我已经尝试通过 SPFile openBinary 方法下载文档。但它只适用于文档较小的情况。请参考以下网站。

getting ComException while reading the document in SharePoint 2010

提前致谢。

【问题讨论】:

    标签: sharepoint-2010 comexception unauthorizedaccessexcepti


    【解决方案1】:

    可能是local loopback check。 (通过在您的 SharePoint 服务器上运行的 IE 尝试使用相同的 URL 访问您的网站进行验证)

    还有 - 为什么您使用 Web 服务而不是 SharePoint 对象模型 (Microsoft.SharePoint.dll) 来访问本地内容?

    【讨论】:

    猜你喜欢
    • 2012-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 2016-09-23
    相关资源
    最近更新 更多