开发者

Getting 401 error when trying to read file from sharepoint repository

I have been using this code to read in a file from a document repository in sharepoint:

WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create("http://servername/realestate/SiteAssets/navigation.txt");
objRequest.Timeout = 10000;
objRequest.UseDefaultCredentials = true;
objRequest.Proxy.Credentials = objRequest.Credentials;

objResponse = (WebResponse)objRequest.GetResp开发者_开发问答onse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
{
    navBar = sr.ReadToEnd();
    sr.Close();
}

I just migrated to a new environment, and I am getting a 401 unauthorized error with this code - but, instead of using servername, I am now using hostname (since the new environment has a domain assigned to it). How can I navigate this issue, even though I am now using a host in my HttpWebRequest object? And, if this should not be causing the issue, I would like to hear recommendations as well. Thanks.


Local Loopback check?

KB 896861 - You receive error 401.1 when you browse a Web site that uses Integrated Authentication and is hosted on IIS 5.1 or a later version

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜