此文来自:http://www.cnblogs.com/fumj/p/3588517.html
手工升级ASP.NET MVC 3项目:
一.安装ASP.NET MVC 4
二.升级ASP.NET MVC版本配置信息:
1:替换项目 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
为最新4.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,
2:在Web.config中升级ASP.NET配置为版本: "2.0.0.0" ,并添加个新的节点:PreserveLoginUrl ,值为 "true":
<appSettings>
<add key="webpages:Version" value="2.0.0.0"/>
<add key="PreserveLoginUrl" value="true"/>
<appSettings>
3:在解决方案浏览器Solution Explorer中,引用最新的Solution Explorer, 删除System.Web.Mvc System.Web.Mvc (v4.0.0.0).
删除引用:
- System.Web.Mvc (v3.0.0.0)
- System.Web.WebPages (v1.0.0.0)
- System.Web.Razor (v1.0.0.0)
- System.Web.WebPages.Deployment (v1.0.0.0)
- System.Web.WebPages.Razor (v1.0.0.0)
添加引用:
- System.Web.Mvc (v4.0.0.0)
- System.Web.WebPages (v2.0.0.0)
- System.Web.Razor (v2.0.0.0)
- System.Web.WebPages.Deployment (v2.0.0.0)
- System.Web.WebPages.Razor (v2.0.0.0)
4:
在解决方案浏览器Solution Explorer,卸载当前项目,编辑ProjectName.csproj.
找到ProjectTypeGuids 元素,并替换{E53F8FEA-EAE0-44A6-8774-FFD645390401} 为 {E3E379DF-F4C6-4180-9B81-6769533ABE47}.
保存修改,关闭(.csproj) 文件,然后重新加载项目.
5:如果项目中有第三方组件引用了老版本的ASP.NET MVC, 可以在Web.config中加入三个 bindingRedirect元素
<configuration>
<!--... elements deleted for clarity ...-->
<runtime>
<assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirectold Version="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirectold Version="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/> <!--注意BrnShop原来是3.0.0.0 -->
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirectold Version="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
这样升级就结束了。
此文来自:http://www.cnblogs.com/fumj/p/3588517.html
以下由本人解决记载
另修改:
Presentation\BrnShop.Web\Themes\Default\Views\web.config 文件
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
改成:
<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" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
改成:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
另注:上以的改动。在所有的web.config都需要修改到。比如你只修改了上面代码。当你运行网站时,管理后台(BrnShop.Web.Admin)是进不去的,也需要改动如上代码