Hi Everyone,
We are getting 401 (unauthorised access) error while trying to access edms or SharePoint link from code behind, following is the block of code that is used to access the edms or SharePoint link.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(txtLink.Text);
request.UseDefaultCredentials = true;
request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
request.ImpersonationLevel = TokenImpersonationLevel.Delegation;
CookieContainer cookiescont = new CookieContainer();
request.CookieContainer = cookiescont;
request.AllowWriteStreamBuffering = false;
request.PreAuthenticate = true;
request.AllowAutoRedirect = true;
WebResponse wsc = request.GetResponse();
Note: Following are the environmental and other details.
1. Website is devloped in .net 3.5
2. The website is hosted on IIS 6.0 AND Windows 2003.
3. Following is the setting in web.config
<authentication mode="Windows">
</authentication>
<authorization>
<deny users="?" />
</authorization>
4. Surprisingly: Same block of code is working on my local machine which have XP and IIS 5.1
Any help will be greatly appreciated.
Regards,
Anuj Chauhan
[contact details removed]