HttpWebRequest 410 Status Code - Username + Password are correct

G

Guest

Anyone who can help here is much appreciated. I am trying to
programmatically log onto a website. I am using the code provided in VS for
the AuthenticationManager Class example (
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSystemNetAuthenticationManagerClassTopic.htm
). I have also download and tried to use the following CsharpHttp executable
in an attempt to find my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;303436

Nothing seems to want to work. It doesn't matter if I set PreAuthenticate
to true, it doesn't matter if I set Keep-Alive to true, etc., etc., etc. I
can log into the website through IE with my username/password, but setting
the credentials just won't fly. I used to use a simple OpenUrl in VB and
that has no problem. I was hoping to move up in the world, but I've already
spent more than a week researching this one issue to no avail. Please help.

Here's what I get back:


The following authentication modules are now registered with the system:

Module : System.Net.DigestClient
CanPreAuthenticate : True

Module : System.Net.NegotiateClient
CanPreAuthenticate : True

Module : System.Net.KerberosClient
CanPreAuthenticate : True

Module : System.Net.NtlmClient
CanPreAuthenticate : True

Module : Mssc.Services.Authentication.CustomBasic
CanPreAuthenticate : False

Headers: Date: Thu, 14 Apr 2005 21:38:52 GMT
Server: Apache/1.3.26 (Unix) mod_macro/1.1.2 mod_perl/1.24
WWW-Authenticate: Basic realm="Welcome to Manheim Online"
Last-Modified: Fri, 07 Feb 2003 16:27:50 GMT
ETag: "5ec1c4-ee-3e43de86"
Accept-Ranges: bytes
Content-Length: 238
Connection: close
Content-Type: text/html



Authentication Failed, Unauthorized
Status Code: 401
Status Description: Authorization Required
 
A

Alex Passos

Hi Noel,

It looks at first glance that you are attempting Windows Authentication?
The response from the server wants BASIC authentication which is very
different as the username and password are just passed in as clear text
encoded in base64 to the web server. You may want to do a search on Google
for HTTP headers and WWW-Authenticate to see exactly how it works in basic
mode and see how you will need to send headers to the server in order to
authenticate.

Alex
 
C

Chris R. Timmons

"=?Utf-8?B?Tm9lbCBWb2xpbg==?=" <Noel
(e-mail address removed)> wrote in
Anyone who can help here is much appreciated. I am trying to
programmatically log onto a website. I am using the code
provided in VS for the AuthenticationManager Class example (
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfSy
stemNetAuthenticationManagerClassTopic.htm ). I have also
download and tried to use the following CsharpHttp executable
in an attempt to find my problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;303436

Nothing seems to want to work. It doesn't matter if I set
PreAuthenticate to true, it doesn't matter if I set Keep-Alive
to true, etc., etc., etc. I can log into the website through IE
with my username/password, but setting the credentials just
won't fly. I used to use a simple OpenUrl in VB and that has no
problem. I was hoping to move up in the world, but I've already
spent more than a week researching this one issue to no avail.
Please help.

Check out this blog entry to see what happens at the HTTP level when
using NTLM authentication in a web browser:

http://www.codinghorror.com/blog/archives/000263.html
 
G

Guest

Alex,
Thanks for your response, but accorging to MSDN:

"The proxy's preauthenticate property can be set to true or false. Set it
to true (as shown in the above code) to supply specific authentication
credentials to cause a WWW-Authenticate HTTP header to be passed with the
initial request. This stops the Web server denying access on the initial
request, and performing authentication on the subsequent request."

I have tried many times setting the property, with no avail. Also, the
NetworkCredential constructor that I am using should be automatically setting
the username and password to Base64 encoded. I certain there is something
very basic that I have overlooked and I will continue to look into your
suggestion to make sure I have fully understood. Please let me know if you
can think of anything else.

Thank you,

Noel Volin
 
G

Guest

Reader Helper:

I have managed to get things to this point:

Headers: Date: Fri, 15 Apr 2005 15:35:17 GMT
Server: IBM-HTTP-Server/1.0
Set-Cookie: inetmmr=97686282.44070.0000; expires=Fri, 15-Apr-2005 18:35:17
GMT;
path=/,JSESSIONID=0000CJVQT3NKR5LCDI1QARKHU2A:vlpo57ja;Path=/
Accept-Ranges: bytes
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 12
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-Control: no-cache="set-cookie,set-cookie2"
Content-Language: en
Via: 1.1 www.manheim.com
X-Cache: MISS from www.manheim.com
Connection: close



Authentication Failed, InternalServerError
Status Code: 500
Status Description: Internal Server Error


Although, I am not certain as to why I am getting the 500 Error. Anyone
have any ideas?? I've set the cookie container on the HttpWebRequest,
however, the exception still hits on the HttpWebResponse. I have set the
AllowAutoRedirect = true.

All suggestions welcomed.

Thank you,

Noel Volin
 
G

Guest

Persistence is the most productive quality!

I have solved my issue. For those experiencing the same, the root of the
problem resided in the lackin of HttpWebRequest.Accept:

myWebRequest.Accept = @"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*";

Thanks to everyone who so kindly responded to my problem/issue.

Noel Volin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top