BrnShop mvc3升級mvc4

此文來自:http://www.cnblogs.com/fumj/p/3588517.htmlhtml

手工升級ASP.NET MVC 3項目:web

一.安裝ASP.NET MVC 4瀏覽器

二.升級ASP.NET MVC版本配置信息:app

     1:替換項目 Web.config 中的post

    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,ui

  2:在Web.config中升級ASP.NET配置爲版本: "2.0.0.0" ,並添加個新的節點:PreserveLoginUrl ,值爲 "true":spa

  <appSettings>
  <add key="webpages:Version" value="2.0.0.0"/>
  <add key="PreserveLoginUrl" value="true"/>
  <appSettings>xml

  3:在解決方案瀏覽器Solution Explorer中,引用最新的Solution Explorer, 刪除System.Web.Mvc System.Web.Mvc (v4.0.0.0).htm

        刪除引用:

  • 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)是進不去的,也須要改動如上代碼

相關文章
相關標籤/搜索