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
My case was upgrading from mvc4 to mvc5.
I made sure my references were in sync (with a newly created mvc5 app), updated the web.config file accordingly and it still didn't work. It finally worked when i changed my web.config file (INSIDE THE VIEWS directory) from:
To this:
REMEMBER: stop iis (express or native), clean solution, build and Run.