在web.config中查找下面每一行代码:
System.Web.Mvc, Version=3.0.0.0 System.Web.WebPages, Version=1.0.0.0 System.Web.Helpers, Version=1.0.0.0 System.Web.WebPages.Razor, Version=1.0.0.0
System.Web.Mvc, Version=4.0.0.0 System.Web.WebPages, Version=2.0.0.0 System.Web.Helpers, Version=2.0.0.0 System.Web.WebPages.Razor, Version=2.0.0.0
<appSettings> <add key="webpages:Version" value="2.0.0.0" /> <add key="PreserveLoginUrl" value="true" /> </appSettings>
ASP.NET MVC 4
(可选) jQuery, jQuery Validation and jQuery UI
(可选) Entity Framework
(可选) Modernizr
注:或直接删除项目中注:或直接删除项目中原有的 System.Web.Mvc 3.0.0.0、System.Web.WebPages 1.0.0.0,重新引用System.Web.Mvc 4.0.0.0、System.Web.WebPages 2.0.0.0
第四步:在解决方案管理器上右击MVC项目名称,选择“Unload Project”,然后再右击一次,选择"Edit ProjectName.csproj"。
第五步:在ProjectTypeGuids节点下查找{E53F8FEA-EAE0-44A6-8774-FFD645390401},替换为{E3E379DF-F4C6-4180-9B81-6769533ABE47}
第六步:保存更改,然后再次右击MVC项目名称,选择Reload Project。
第七步:如果你的项目引用了三方类库,并且这些类库是针对老版本的MVC编译的话,打开站点根目录下的web.config,在configuration section下增加下面3个bindingRedirect元素:
<configuration> <!--... elements deleted for clarity ...--> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>