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
Problem:
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\rbs.ceds.todomvcdemo\73d0b7c7\46e3986d\assembly\dl3\21020800\101279fc_da94cf01\System.Web.WebPages.Razor.dll'.
Identification:
The error is with the configuration file i.e. web.config of your project.
Here you will find that Razor version is set to 2.0.0.0 where as in your project 2.0.0.0 version is not available.
Solution:
It is simple, just change the version from 2.0.0.0 to 3.0.0.0 and it will do the magic.
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0 type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0
You don't need to put redirection or so as it will make things complicated.