Configuration error while using Areas in ASP.NET MVC 4

asp.netasp.net-mvc-4

After upgrading to ASP.NET MVC 4, application is breaking on accessing any webpage defined inside an Area

Error screen shot

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred creating the configuration section handler for system.web.webPages.razor/host: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=__WebPagesVersion__.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />

Best Answer

Added this as an answer from comment:

Change Version=_WebPagesVersion_.0.0 to Version=2.0.0.0

Alternatively see if you have any other web.config files floating about in your project and see what values are used there - I understand that sometimes if you have multiple web.config referencing different version of the hosts section it can get quite upset. BTW there is no need to uninstall MVC 3 before 4 - they co-exist happily!