Could not load file or assembly System.Web.Http.WebHost after published to Azure web site
Solution 1:
The dll
is missing in the published (deployed environment). That is the reason why it is working in the local i.e. Visual Studio but not in the Azure Website Environment.
Just do Copy Local = true
in the properties for the assembly(System.Web.Http.WebHost) and then do a redeploy, it should work fine.
If you get the similar error i.e. some other assembly missing, then make that assembly to copylocal=true and redeploy, repeat this iteratively - if you are unsure of its dependencies.
Solution 2:
If you are still looking for an answer, try checking this question thread. It helped me resolve a similar problem.
edit:
The solution that helped me was to run Update-Package Microsoft.AspNet.WebApi -reinstall
from the NugGet package manager, as suggested by Pathoschild.
I then had to delete my .suo file and restart VS, as suggested by Sergey Osypchuk in this thread.
Solution 3:
I met the same problem and I resolved it by setting CopyLocal
to true for the following libs:
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Net.Http.Formatting.dll
I must add that I use MVC4 and NET 4
Solution 4:
For me worked adding the following section to web.config
file:
<configuration>
...
<runtime>
...
<dependentAssembly>
<assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
...
</runtime>
...
</configuration>
This example stands for MVC 5.1. Hope it will help someone to resolve such issue.