Migrating my MVC 3 application to MVC 4

前端 未结 9 2086
难免孤独
难免孤独 2020-12-24 03:08

I really do not know what to do, I\'m following this article that shows how to migrate my MVC 3 application manually .

I followed all the steps but

相关标签:
9条回答
  • 2020-12-24 03:17

    I assumed you have MVC3 Intranet web application, when upgrade from MVC3 to MVC4 using NuGet, your application now references System.Web.WebPages.Razor Version 2.0.0.0, NOT System.Web.WebPages.Razor Version 1.0.0.0 anymore. Here is my way of resolving the reference.

    There are two places to fix:

    1. In the root web.config,

      <compilation debug="true" targetFramework="4.0">
        <assemblies>
          . . .
          <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          . . .
        </assemblies>
      </compilation>
      

    change Version=1.0.0.0 to Version=2.0.0.0

    So your new reference will look like this:

        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            . . .
            <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            . . .
          </assemblies>
        </compilation>
    
    1. In the Views folder, there is web.config file. Inspecting this file you will see it references Version 1. Replace the whole web.config file in Views folder with a new web.config file. Make a backup of the old web.config file, just in case. To get a brand new web.config for the Views folder, you create a new MVC4 application for intranet. Go to the Views folder. Copy the Web.Config file from the Views folder of the new application to the Views folder of the broken application.

    Hope it helps!

    0 讨论(0)
  • 2020-12-24 03:20

    Have you globally searched for System.Web.WebPages.Razor, Version=1.0.0.0 in your entire solution? Do you still reference System.Web.WebPages.Razor (Version 1.0.0.0)? Do you reference System.Web.WebPages.Razor Version 2.0.0.0?


    [Update] I finally ran into the same issue. It seems like one of the NuGet packages I installed and uninstalled didn't entirely remove the reference to System.Web.Razor it used. Cleaning the solution didn't help because the DLL wasn't used directly by the web application. I finally got it to work by manually deleting the entire bin directory ...

    0 讨论(0)
  • 2020-12-24 03:22

    this is very simple, when you update to MVC 4.0.0.0 ,but the webconfig in the solution still points to MVC 3.0.0.0.0. so just replace MVC version 3.0.0.0.0. by 4.0.0.0.0

    Do the same with other assemblies, to check the version of assembly , check properties of the respective assembly in references in your project.

    0 讨论(0)
  • This is another Nuget package that u can use to upgrade mvc 3 to mvc 4 https://nuget.org/packages/UpgradeMvc3ToMvc4

    0 讨论(0)
  • 2020-12-24 03:30

    My application used a third-party package, the AspNetSprites-MvcAndRazorHelper. Reinstalled this package and the error of the reference was corrected.

    0 讨论(0)
  • 2020-12-24 03:32

    Did you forget to update the references in Views\Web.Config? The references in it is used to build the view pages.

    0 讨论(0)
提交回复
热议问题