I have a problem like this on server
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration
This issue is very common when you are developing for MVC 4 and then suddently you install a package which is available in newer version so it breaks entire application.
Only solution to such issue is to upgrade your entire application to newer or install the old package compatible with your application
In the root Web.config make sure assemblyBinding contains the proper version for the assembly "System.Web.WebPages.Razor" and "System.Web.Mvc". Check for their actual existence as well as my "System.Web.WebPages.Razor" assembly tag was missing causing the error. I had my assembly versions set to 3.0 and 5.0 respectively in the time of this writing with full NuGet updates. Code should look something like below. The publicKeyToken will stay the same between the versions. Cheers!
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!--some more bidings-->
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor"
publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<!--some more bidings-->
</assemblyBinding>
Ian's solution worked in one project, but for others I need the more complete info in How to Upgrade to MVC 5 and Web API 2