开发者

401 unauthorized exception while reading data from the document library SharePoint 2010

We developed a WebPart to read the content of the file in the document library in the SiteCollection. I used the following code to read the content.

 WebClient wc = new WebClient();
 wc.Credentials = CredentialCache.DefaultNetworkCredentials;
 string documenturl = siteurl+"/" + file.Url.ToString();
 content = wc.Download开发者_如何学运维Data(documenturl);//documenturl is the file path of the document

But, i got the following error 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)

For your information, i already tried to download document by SPFile openBinary method. But it only works when the document is small. Please refer the below site.

getting ComException while reading the document in SharePoint 2010

Thanks in advance.


Probably the local loopback check. (Verify by trying to access your site using the same URL whilst using IE running on your SharePoint server)

Also - any reason why you're using web services to access local content rather than the SharePoint object model (Microsoft.SharePoint.dll)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜