How to get 'System.Web.Http, Version=5.2.3.0?

asp.net Mvcasp.net Mvc-5Nuget

asp.net Mvc Problem Overview


I just created an MVC5 project and added several packages from nuget, but then when I compiled the project, i got this error. It seems one of the packages really depends on system.web.http version 5.2.3.0, which i couldn't find anywhere. I just wonder how to get the latest version of system.web.http ?

Error	2	Assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
d:\Backup 2014-12-25\Website-Projects\www.ptsol.com.au\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

In Package Manager Console

Install-Package Microsoft.AspNet.WebApi.Core -version 5.2.3

Solution 2 - asp.net Mvc

One way to fix it is by modifying the assembly redirect in the web.config file.

Modify the following:

<dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>

to

<dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="4.0.0.0" />
</dependentAssembly>

So the oldVersion attribute should change from "...-4.0.0.0" to "...-5.2.3.0".

Solution 3 - asp.net Mvc

I did Install-Package Microsoft.AspNet.WebApi.Core -version 5.2.3 but it still did not work. Then looked in my project bin folder and saw that it still had the old System.Web.Mvc file.

So I manually copied the newer file from the package to the bin folder. Then I was up and running again.

Solution 4 - asp.net Mvc

Install-Package Microsoft.AspNet.WebApi.Core -version 5.2.3

Then in the project Add Reference -> Browse. Push the browse button and go to the C:\Users\UserName\Documents\Visual Studio 2015\Projects\ProjectName\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45 and add the needed .dll file

Solution 5 - asp.net Mvc

The packages you installed introduced dependencies to version 5.2.3.0 dll's as user Bracher showed above. Microsoft.AspNet.WebApi.Cors is an example package. The path I take is to update the MVC project proir to any package installs:

Install-Package Microsoft.AspNet.Mvc -Version 5.2.3

https://www.nuget.org/packages/microsoft.aspnet.mvc

Solution 6 - asp.net Mvc

Uninstalling and re-installing the NuGet package worked for me.

  1. Remove any old reference from the project.

Execute this in the Package Manager Console:

  1. UnInstall-Package Microsoft.AspNet.WebApi.Core -version 5.2.3
  2. Install-Package Microsoft.AspNet.WebApi.Core -version 5.2.3

Solution 7 - asp.net Mvc

install this in your nuget package manager

Install-Package Microsoft.AspNet.WebApi.WebHost -Version 5.2.7

and paste

using System.Web.Http;

This should work

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
QuestionJohn HadikusumoView Question on Stackoverflow
Solution 1 - asp.net MvcRoman PatutinView Answer on Stackoverflow
Solution 2 - asp.net MvcBracherView Answer on Stackoverflow
Solution 3 - asp.net MvcBob KouryView Answer on Stackoverflow
Solution 4 - asp.net MvcVitali SiamenauView Answer on Stackoverflow
Solution 5 - asp.net MvcDouglas WileyView Answer on Stackoverflow
Solution 6 - asp.net MvcRam Kishore KView Answer on Stackoverflow
Solution 7 - asp.net MvcRixantView Answer on Stackoverflow