Last post Oct 09, 2007 11:36 PM by Guang-Ming Bian - MSFT
Oct 04, 2007 06:11 PM|mikesudev|LINK
We wrote a reverse proxy and use Windows Authentication in our websites. The first time the user connects, an exception occurs (401 Unauthorized). The code we use is the following:
Dim uri As Uri = New Uri(_remoteServer + OPEN_BRACKET + context.Session.SessionID + CLOSE_BRACKET + url)
_request = CType(WebRequest.Create(uri), HttpWebRequest)
_request.PreAuthenticate = True
_request.Credentials = CredentialCache.DefaultCredentials
Dim response As HttpWebResponse = DirectCast(_request.GetResponse(), HttpWebResponse) ' HERE THE EXCEPTION OCCURS
Is there anything that we forgot to set? If not how can we handle the exception and resend a request?
Thanks a lot.
Oct 09, 2007 11:36 PM|Guang-Ming Bian - MSFT|LINK
The DefaultCredentials property applies only to NTLM, negotiate, and Kerberos-based authentication. Please set a breakpoint to check whether
DefaultCredentials has the right value. You can also use a true user name and password to test whether has the same problem.
Dim cr As New System.Net.NetworkCredential("user",
Dim pr As New System.Net.WebProxy("127.0.1.2", 80)
There is a good article which may help you:
Guang-Ming Bian - MSFT