HttpWebRequest with Digest authentication returns error 401 in metro app (windows 8)

I'm developing an app for Windows 8 (metro app) that needs to download some content from a server that requires Digest authentication.

This is the code I'm using to send the request:

WebRequest webRequest = WebRequest.Create("http://my_site_with_http_digest_auth");
webRequest.Method = "GET";
webRequest.Credentials = new NetworkCredential("user", "pass");
webRequest.UseDefaultCredentials = false;
HttpWebResponse webResponse = (HttpWebResponse)await webRequest.GetResponseAsync();
if (webResponse != null && webResponse.StatusCode == HttpStatusCode.OK)
{
    // Analyze response here...
}

When I run this code in a metro app, the server returns 401 (authentication error). The exactly same code runs well on Windows Phone and a normal .NET app. This only happens on Windows 8 metro app. Maybe this is a bug in WinRT. Someone else has experienced this problem in metro apps? Any tip?

Answers


Potentially this is another manifestation of a more general bug in .NET Framework

https://connect.microsoft.com/VisualStudio/feedback/details/571052/digest-authentication-does-not-send-the-full-uri-path-in-the-uri-parameter

(voting not allowed on that one!)

And another report:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/5b66153e-6b02-4523-b17f-3c6b711345ed/httpclient-digest-authentication-does-not-work-if-the-uri-has-querystring-parameters

And (with bizarre MSFT response):

http://connect.microsoft.com/VisualStudio/feedback/details/786592/webclient-digest-authentication-does-not-work-if-the-uri-has-querystring-parameters

Finally:

Implement Digest authentication via HttpWebRequest in C#


Need Your Help

Best strategy for adding or updating a collection of related entities when using the EF4?

c# .net entity-framework

Let's say you have a Classroom entity with an collection of Student entities. What I usually do when creating a new Student and need to add it to the Classroom is use Classroom.Students.Add(newStud...

function F() { if (!(this instanceof F)) { return new F() }; ... }

javascript

What is the usage of the construct: function F() { if (!(this instanceof F)) { return new F() }; ... }?