Friday, November 30, 2012

MVC 3 to MVC 4 Project Upgrade Configuration Error __WebPagesVersion__.0.0

I've seen a few posts on forums like Stack Overflow recently regarding issues when upgrading from an MVC3 to an MVC4 site regarding Web Pages version configuration. Whilst I haven't experienced the problem myself it revolves around web.configs


Presumably this is meant to be replaced by a version number but in some cases isn't and so the whole entry looks like so:


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

To fix the error simple replace the __WebPagesVersion__ with 2.0 so it looks like the following


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

It's also worth running Find in files for this errant string and/or checking any other web.configs in your solution and ensuring that the Version reference is 2.0.0.0 and not 1.0.0.0 or ___WebPagesVersion___.


References:

http://stackoverflow.com/questions/13443152/configuration-error-while-using-areas-in-asp-net-mvc-4/13585812#13585812 


http://www.asp.net/whitepapers/mvc4-release-notes
Read More