Where can I find a NuGet package for upgrading to System.Web.Http v5.0.0.0?

C#.Netasp.net Mvc-4Nugetasp.net Web-Api2

C# Problem Overview


Just upgraded an ASP.NET MVC4 project to use Unity.WebApi version 5.0.0.0 and it requires System.Web.Http v 5.0.0.0 as per the following error:

Assembly 'Unity.WebApi, Version=5.1.0.0, Culture=neutral, PublicKeyToken=43da31bc42a85347' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'   

I am currently referencing System.Web.Http v4.0 but have the following NuGet packages upgraded to their respective latest versions:

  • ANTLRv3

  • Microsoft ASP.NET Universal Providers

  • Microsoft.Web.Infrastructure

  • Microsoft ASP.NET MVC

  • Microsoft ASP.NET Razor

  • Microsoft ASP.NET Universal Providers Core Libraries

  • Microsoft ASP.NET Universal Providers

  • Microsoft ASP.NET Web API 2 Client

  • Microsoft ASP.NET Web API 2 Core

  • Microsoft ASP.NET Web API 2 Web Host

  • Microsoft ASP.NET Web API 2

  • Microsoft ASP.NET Web Page

  • Microsoft.Web.Infrastructure

  • WebGrease

    via NuGet. I have not listed relevant JavaScript libraries such as Micrososft.jQuery.Unobtrusive Validation, etc.

What is the NuGet package to upgrade System.Web.Http or do I have to do this manually?

C# Solutions


Solution 1 - C#

You need the Microsoft.AspNet.WebApi.Core package.

You can see it in the .csproj file:

<Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll</HintPath>
</Reference>

Solution 2 - C#

I have several projects in a solution. For some of the projects, I previously added the references manually. When I used NuGet to update the WebAPI package, those references were not updated automatically.

I found out that I can either manually update those reference so they point to the v5 DLL inside the Packages folder of my solution or do the following.

  1. Go to the "Manage NuGet Packages"
  2. Select the Installed Package "Microsoft ASP.NET Web API 2.1"
  3. Click Manage and check the projects that I manually added before.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKlaus NjiView Question on Stackoverflow
Solution 1 - C#user247702View Answer on Stackoverflow
Solution 2 - C#TonyView Answer on Stackoverflow