I\'ve just uploaded a Asp.Net Web Api 2.2 project to production server and I got the error stated in the title.
In my Web.config I already have this:
Adding below config inside web.cofig solved my issue.
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.5.0" />
</dependentAssembly>
Another way to do this, which do not require a New build or update/reinstall With Nuget is to do the following in config.web:
For the dll you have issues With, do the following:
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.2.2.0">
I had an issue today, and this little tweak solved it...
I ran into the same exact error. It was caused by a script I was using to deploy the application which replaced the Web.config with a previous version. The Web.config was specifying the wrong version of System.Web.Http. Removing that step solved the problem.
I solved the problem into the following steps:
One click publishing did not replace the correct version of dll or the remote site was keeping the file in use.
Set Copy Local
to true
in the properties for the System.Web.Http
and System.Web.Http.WebHost
assemblies and redeploy the package.
If this doesn't solve your problem completely try reinstalling the NuGet package. This will hopefully correct broken dependencies. From the package management console, run this command:
Update-Package Microsoft.AspNet.WebApi -reinstall
Make sure to install System.Web.Http.WebHost
as well.