Perhaps an earlier version of System.Web.WebPages.dll is loaded into memory and tries to pass your cshtml page to the version of the WebPages class from this DLL.
To check this, try looking at which http modules are currently registered:
var allModules = HttpContext.Current.ApplicationInstance.Modules; for( int i = 0; i < allModules.Count; i++ ) { Trace(allModules.GetKey(i)); }
In my case, it was:
.... __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_bca8e05a-5746-45b0-be95-2b920b455ccf __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_c1a67b42-31a9-47f1-8483-9e712fabe2a7
To fix this problem, you need to replace the older version of System.Web.WebPages.dll in the / Bin folder or some other dll files that may link to it.
Dmitry Dzygin
source share