I did the upgrade according to. http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
I get the er
Just an obvious but possible helpful hint....remember to check that the new version you specify in your webconfig assembly binding is the same version that you reference in your project references. (ie as I write this...this would be 5.1.0.0 if you have recently done a NUGet on System.Web.Http
What solved the problem for me was re-installing the Microsoft ASP.NET Web API 2.2 Help Page and Microsoft ASP.NET Web API 2.2 OWIN packages. I re-installed both at the same time, but I think it was the former that fixed the issue.
I tried the first few of the solutions offered here but that didn't help, then I compared my dependencies with the ones in a project that worked (from a course on Pluralsight) and the two dependencies above were a lower version (5.0.0) so I updated them to 5.2.3 and it started working.
ASP.NET Version:4.0.30319.18408 belongs to .Net4.5 and System.Web.Http Version=4.0.0.0 is compatible for .NET4.0. So the versions that you have are not compatible. You should update you System.Web.Http to version 5.0.0.0, which is compatible with .Net4.5
I had the same problem with System.Web.Http.WebHost, Version=5.2.6.0 being referenced but the latest NuGet package was 5.2.7.0. I edited the web.config files, re-installed the NuGet package, then edited the visual studio project files for all of my projects to make sure no references to 5.2.6.0 persisted. Even after all this, the problem persisted.
Then I looked in the bin folder for the project that was throwing the exception, where I found a DLL for one of my other projects that is not a dependency and should never have been there. I deleted the offending DLL (which had been compiled using the 5.2.6.0 version of System.Web.Http.WebHost), rebuilt the troublesome project, and now it is working.
I had a similar issue. Everything was working before. It's was originally made using Web Forms and later on added Web API for some things.
What worked was, in Visual Studio, change publish profile settings from Release to Debug. Strange, but that's what worked. So sharing here.
You need to add assembly redirects:
<configuration>
....
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
...
</configuration>
Most likely you have to do this for a few more assemblies like webhosting, etc.