RE: 401.1 Error when calling an asp.net page from code.
- From: blevitt <blevitt@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Jul 2009 07:35:02 -0700
Nevermind. This turned out to be the loopback check issue:
http://support.microsoft.com/kb/896861
We opted for method 2.
"blevitt" wrote:
aspx page A and aspx page B are on the same server. I'm using the code below.
in aspx page A to call aspx page B. This works fine in our qa and dev
environments but fails in our production environment. Using the default
credentials also works in dev and qa. In production, the
httpRequest.GetResponse() call throws an error and looking at the
WebException response it shows page be responded with:
HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials.
If I connect to page B directly it works fine (even if using the same
credentials I'm using in code). When using DefaultCredentials I thought that
I had an NTLM double hop issue, but adding credentials voids that I think.
I'm running out of ideas. The only other difference on this box that I'm
aware of is that it is load balanced (although at the moment it only has one
node).
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(helperURL);
httpRequest.Credentials = new NetworkCredential("username", "password");
//httpRequest.Credentials = CredentialCache.DefaultNetworkCredentials;
//httpRequest.UseDefaultCredentials = true;
//httpRequest.PreAuthenticate = true;
StreamReader reader;
XmlDocument xmlDoc = new XmlDocument();
try
{
using (HttpWebResponse httpResponse =
(HttpWebResponse)httpRequest.GetResponse())
{
reader = new StreamReader(httpResponse.GetResponseStream());
xmlDoc.Load(reader);
}
}
catch (System.Net.WebException ex)
{
throw new ApplicationException(
"Data helper threw http 500 error:\r\n"
+ DumpHttp(httpRequest, ex.Response)
);
}
- References:
- 401.1 Error when calling an asp.net page from code.
- From: blevitt
- 401.1 Error when calling an asp.net page from code.
- Prev by Date: 401.1 Error when calling an asp.net page from code.
- Next by Date: microsoft index server problem with idq/htx
- Previous by thread: 401.1 Error when calling an asp.net page from code.
- Next by thread: microsoft index server problem with idq/htx
- Index(es):
Relevant Pages
|