R
Rhywun
The following code snippet (adapted from <a href="http://
authors.aspalliance.com/stevesmith/articles/netscrape.asp">this</a>,
which reads the HTML generated by another page, used to work on
Windows 2000 with whatever version of IIS was current then. Now my
code has been moved to Windows 2003 and (I presume) a newer version of
IIS, and the code no longer works but instead returns a ProtocolError
with a message "The remote server returned an error: (401)
Unauthorized." Inside the Protocol error the message helpfully reads
"Unauthorized".
In web.config, authentication is set to "Windows" and identity
impersonate is on. My authorization simply denies all unauthenticated
users and allows all authenticated users.
Is anyone aware of changes between 2000 and 2003 that break this code?
I've been fiddling with the code and with settings in IIS for a couple
days now without any luck. Many thanks in advance!
PS. The code *does* work from VS2005's built-in web server.
Code:
------------
try
{
String result;
WebRequest request = WebRequest.Create(url);
ICredentials credentials = CredentialCache.DefaultCredentials;
request.Credentials = credentials;
// TODO: Returns 'unauthorized' error on Windows 2003
WebResponse response = request.GetResponse();
using (StreamReader sr = new StreamReader(response.GetResponseStream
()))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
}
authors.aspalliance.com/stevesmith/articles/netscrape.asp">this</a>,
which reads the HTML generated by another page, used to work on
Windows 2000 with whatever version of IIS was current then. Now my
code has been moved to Windows 2003 and (I presume) a newer version of
IIS, and the code no longer works but instead returns a ProtocolError
with a message "The remote server returned an error: (401)
Unauthorized." Inside the Protocol error the message helpfully reads
"Unauthorized".
In web.config, authentication is set to "Windows" and identity
impersonate is on. My authorization simply denies all unauthenticated
users and allows all authenticated users.
Is anyone aware of changes between 2000 and 2003 that break this code?
I've been fiddling with the code and with settings in IIS for a couple
days now without any luck. Many thanks in advance!
PS. The code *does* work from VS2005's built-in web server.
Code:
------------
try
{
String result;
WebRequest request = WebRequest.Create(url);
ICredentials credentials = CredentialCache.DefaultCredentials;
request.Credentials = credentials;
// TODO: Returns 'unauthorized' error on Windows 2003
WebResponse response = request.GetResponse();
using (StreamReader sr = new StreamReader(response.GetResponseStream
()))
{
result = sr.ReadToEnd();
sr.Close();
}
return result;
}