RTM Known Issue: System.Net.Http.HttpClient or HttpWebRequest class usage in a UWP app throws a System.NotSupportedException when the Web Server requires Negotiate/NTLM authentication RRS feed

  • Question

  • When you use the System.Net.Http.HttpClient class from a .NET framework based Universal Windows Platform (UWP) app and send a HTTP(s) PUT or POST request to a URI which requires Integrated Windows Authentication – such as Negotiate/NTLM, an exception will be thrown.

    The thrown exception will have an InnerException property set to the message:

    “This IRandomAccessStream does not support the GetInputStreamAt method because it requires cloning and this stream does not support cloning.”

    The problem happens because the request as well as the entity body of the POST/PUT request needs to be resubmitted during the authentication challenge. The above problem does not happen for HTTP verbs such as GET which do not require an entity body.

    This is a known issue in the RTM release of the Windows 10 SDK and we are tracking a fix for this issue for a subsequent release.

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, August 4, 2015 8:22 PM


  • If you encounter this issue, please consider using the Windows Runtime API: Windows.Web.Http.HttpClient class to access the same resource.

    Here are a few links to help you get started:

    MSDN documentation: https://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.aspx

    Windows Universal HttpClient sample: https://github.com/Microsoft/Windows-universal-samples/tree/master/httpclient

    For example, you can use code similar to the below to access the resource using the Windows.Web.Http.HttpClient:

    Windows.Web.Http.Filters.HttpBaseProtocolFilter hbpf = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
    Windows.Security.Credentials.PasswordCredential pcred = new Windows.Security.Credentials.PasswordCredential(“targetURL”, “yourUserName”, “yourPassword”);
    hbpf.ServerCredential = pcred;
    Windows.Web.Http.HttpClient hc = new Windows.Web.Http.HttpClient(hbpf);
    Windows.Web.Http.HttpRequestMessage hreqm = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, new Uri(“targetURL”));
    Windows.Web.Http.HttpStringContent hstr = new Windows.Web.Http.HttpStringContent(“<content you intend to post>”);                
    hreqm.Content = hstr;
    Windows.Web.Http.HttpResponseMessage hrespm = await hc.SendRequestAsync(hreqm);
    // consume the HttpResponseMessage and the remainder of your code logic from here.


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, August 4, 2015 8:23 PM