HttpWebRequest & (401) Unauthorized http status code
I would appreciate any help with the following, havn't found any answers for this in my research to date.
I am trying to retreive a web page (a htm file intially) from a vdir on an intranet site using the following code, where the vdir has "Integrated Windows authentication" turned on but "Anonymous access" turned off, i get the following message
The remote server returned an error: (401) Unauthorized.
If i use the browser i can see the page with no problems.
If i enable "Anonymous access", the below will work but this completly defeats the purpose of turning on "Integrated Windows authentication".
I have seen web posts where people using some COM components in VB6.0 can get this to work but for some reason the HttpWebRequest being used below will not work event though i have set the PreAuthenticate property.
private static void HttpGet(string strUrl)
HttpWebRequest _Request = null;
HttpWebResponse _Response = null;
Stream _ResponseStream = null;
StreamReader _ResponseStreamReader = null;
string _strResponse = string.Empty;
// Instantiate request setting header properties
_Request = (HttpWebRequest) WebRequest.Create(strUrl);
_Request.Method = "GET";
_Request.ContentType = "text/xml";
_Request.PreAuthenticate = true;
_Request.Proxy = WebProxy.GetDefaultProxy();
_Request.Proxy.Credentials = CredentialCache.DefaultCredentials;
// Get response
_Response = (HttpWebResponse) _Request.GetResponse();
_ResponseStream = _Response.GetResponseStream();
_ResponseStreamReader = new StreamReader(_ResponseStream, Encoding.UTF8);
_strResponse = _ResponseStreamReader.ReadToEnd();
// Close response stream
// Write out response
catch (Exception GenericException)
Thanks in advance
|All times are GMT. The time now is 09:58 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.