Visual Studio 2015 Razor View MVC Types not recognized

后端 未结 7 1392
Happy的楠姐
Happy的楠姐 2020-12-30 20:21

I installed Visual Studio 2015 and rebooted. The \"MVC\" types are not recognized in 2015 but are still recognized in 2013. This is my \"Views\" web.config:

相关标签:
7条回答
  • 2020-12-30 20:40

    It didn't work for me. It seems that this issue has several root causes related to web.config.

    One another problem was root web.config compilation version mismatch.

    <compilation debug="true" targetFramework="4.5.2">
    
    <httpRuntime executionTimeout="600" maxRequestLength="10240" requestValidationMode="2.0" targetFramework="4.5.2" />
    

    If httpruntime version is different from the assembly's this may happen.

    0 讨论(0)
  • 2020-12-30 20:41

    From Chris Zhao on asp.net: You could consider uninstalling VS 2015, and reinstall it again,and check whether "Web Developer tools" is selected [go into Custom during the installation to be sure it is checked.

    I did this and it got rid of the red underlines under Viewbag.

    0 讨论(0)
  • 2020-12-30 20:43

    If you upgraded from MVC4 to MVC5: in Views/web.config change

       <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    

    to

       <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    
    0 讨论(0)
  • 2020-12-30 20:47

    I think similar problem was described here - https://stackoverflow.com/q/22832435/3350527. Old version of System.Web.Mvc in use (by VS 2015 opinion).

    0 讨论(0)
  • 2020-12-30 20:55

    I discovered that I needed to bump the version for the assemblies dealing with the config sections to 3.0.0.0 in the Views/Web.config file:

      <configSections>
        <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>
      </configSections>
    

    They were previously all 2.0.0.0.

    0 讨论(0)
  • 2020-12-30 20:56

    I've tried many things to resolve this issue. To name a few:

    1. Checking and un-checking Tools->Text Editor->All Languages-> Auto List Members and Parameter information
    2. Restarting Visual Studio
    3. Deleting all sorts of file(s) in various folders:bin, *.sou, %AppLocacalData%\Temp and etc.

    Nothing worked.

    Then I've went to Control Panel and run Visual Studio setup and clicked 'Repair' button. After process has finished it offered to restart the machine and after that intellisense started to work again in razor views.

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