HttpWebRequest PreAuthenticate not working for Digest Authentication?

W

Wolfgang Meier

I am using the following code to retrieve a document from my web
server:

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://example.com/");
req.Method = "GET";
req.PreAuthenticate = true;
req.Credentials = new NetworkCredential("user", "pass");
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
res.Close();

When setting my web server to require Basic Authentication, multiple
executions result in the following log entries:
401 Authentication Required
200 OK
200 OK
200 OK

However, when setting my web server to require Digest Authentication,
multiple executions result in:
401 Authentication Required
200 OK
401 Authentication Required
200 OK
401 Authentication Required
200 OK

Seems like old authentication information is not used for new querys to
the same URI.

I also tried using

req.Credentials = new NetworkCredential("user", "pass", "example.com");

but to no avail. This is quite frustrating, as a HTTP PUT to the server
can now only be performed with AllowWriteStreamBuffering set to false.


Did I simply overlook something, or is PreAuthenticate not available
for Digest Authentication?

How can I PUT a file to a server using Digest Authentication while
having AllowWriteStreamBuffering set to false?


I am really hoping someone can help!

Kind regards,

Wolf
 

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

Top