Overview

This page is about the Microsoft.Net.Http package. Our first release announcement can be found here.

Release Notes

Microsoft.Net.Http 2.1.3

  • First release of the portable version of HttpClient
Troubleshooting

Issue 1

Symptom

When installing HttpClient into a project that contains an app.config or web.config with binding redirects, the config file may be incorrectly transformed.  EG:
    <dependentAssembly bcl:name="System.Net.Http">
      <assemblyIdentity name="ExistingAssembly" publicKeyToken="abcdef012345678" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-2.0.43.0" newVersion="2.0.43.0" />
    </dependentAssembly>

Resolution

To fix this you can update the config as follows:
      <dependentAssembly>
        <assemblyIdentity name="ExistingAssembly" publicKeyToken="abcdef012345678" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly bcl:name="System.Net.Http">
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.43.0" newVersion="2.0.43.0" />
      </dependentAssembly>

Issue 2

Symptom 

When using HttpClient from a Silverlight application the FormUrlEncodedContent and MultipartContent classes incorrectly encode content using UTF8 instead of iso-8859-1.

Resolution

At the moment we recommend avoiding use of these classes from a Silverlight application until he issue is fixed.

Issue 3

Symptom 

When using HttpClient from a Silverlight application many http headers are not supported and will result in an ArgumentException or NotImplementedException when set and calling HttpClient methods that send a request.

Resolution

For a list of headers which are not supported in Silverlight please see:
http://msdn.microsoft.com/en-us/library/system.net.webheadercollection(v=vs.95).aspx
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.headers(v=vs.95).aspx

Issue 4

Symptom 

When HttpClientHandler.SupportsProtocolVersion() is false the HttpResponseMessage returned from a request will have a null value for Version.

Resolution

Make sure that anytime you are using a version from the HttpResponseMessage, you do a null check on it if SupportsProtocolVersion() is false.

Issue 5

Symptom 

When using consuming HttpClient in an .Net 4.0, 4.5, or Windows Store application by referencing  portable library project the wrong version of HttpClient is selected for the platform. 

Resolution

To avoid this always install the HttpClient Nuget package in every project that consumes the library (even indirectly).

Issue 6

Symptom 

When using HttpClient on Silverlight or the Phone be aware that the networking stack may cache responses. 

Resolution

To avoid inconsistencies when creating  portable class library that runs on both platforms be sure that your server sets the cache control-header on the response to match your expected caching behavior on the Phone.  If you do not control the server, consider making a portion of the request unique if you do not want a cached result.

Issue 7

Symptom

When consuming a portable class library using HttpClient from a .NET 4.5, Windows Store or Windows Phone 8 application, the application crashes with an exception similar to this:

Method not found: 'Void System.Net.Http.HttpClientHandler.set_AutomaticDecompression(System.Net.DecompressionMethods)'.

Resolution

The application project needs to reference the HttpClient NuGet package as well. 

Issue 8

Symptom

ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Net.Http package may experience a TypeLoadException or other errors after being installed.

Resolution

This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:

  1. Right-click on the project and choose Add Existing Item
  2. Browse to the HttpClient net40 package folder
  3. In the File name text box enter *.*
  4. Holding CTRL, select System.Net.Http.dll and System.Net.Http.Primitives.dll
  5. Click the down-arrow next to the Add button and choose Add as Link
  6. In Solution Explorer, holding CTRL select System.Net.Http.dll and System.Net.Http.WebRequest.dll
  7. Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
  8. Republish