Razor 2 to Razor 3 MVC 5

前端 未结 3 1098
别跟我提以往
别跟我提以往 2021-02-02 05:44

I\'ve been working on an MVC 4 solution, and I\'ve been trying to upgrade it to MVC 5. I\'ve followed the steps outlined here.

I\'ve followed it, and now whenever I run

相关标签:
3条回答
  • 2021-02-02 06:15

    Looks like you still have a reference to Razor 2.0 dll.

    Check your project references' properties - especially 'Use specific version' one.

    0 讨论(0)
  • 2021-02-02 06:17

    Check for version in web.config. If it again gives an error, try to clean the solution and rebuild it. Also check for project's Bin folder, removes old references from bin folder and rebuild the project solution.

    0 讨论(0)
  • 2021-02-02 06:18

    In your Web.config(-s) make sure assemblyBinding contains the proper version for the assembly System.Web.WebPages.Razor and System.Web.Mvc.

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
    
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    

    And make sure that razor sectionGroup in ConfigSections reference latest versions as well:

    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
        <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </sectionGroup>
    
    0 讨论(0)
提交回复
热议问题