无法识别 Visual Studio 2015 Razor View MVC 类型 [英] Visual Studio 2015 Razor View MVC Types not recognized
问题描述
我安装了 Visual Studio 2015 并重新启动.MVC"类型在 2015 年无法识别,但在 2013 年仍被识别.这是我的视图"web.config:
<预><代码><配置><configSections><sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35><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"/></sectionGroup></configSections><system.web.webPages.razor><host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><pages pageBaseType="System.Web.Mvc.WebViewPage"><命名空间><add namespace="System.Web.Mvc"/><add namespace="System.Web.Mvc.Ajax"/><add namespace="System.Web.Mvc.Html"/><add namespace="System.Web.Optimization"/><add namespace="System.Web.Routing"/></命名空间></页面></system.web.webPages.razor>我们相信这些正在发生是因为您当前使用的是 MVC 4,并且 MVC 4 工具不包含在 Visual Studio 2015 中.只有 MVC 5 和 MVC 6 工具是包括.如果您实际上正在使用 MVC 5 并看到这些问题,请告诉我们.您可以通过打开 packages.config 并滚动到 Microsoft.AspNet.Mvc 条目来确认您正在使用 MVC 4.如果列出的版本以4"开头,则表示您使用的是 MVC 4.
话虽如此,我们感谢您的反馈以及您在 MVC 4 中所做的投资.根据您和其他客户的反馈,我们正在研究为 Visual Studio 2015 提供 MVC 4 工具的可能性.同时,尽管存在工具问题,您的项目仍将在 Visual Studio 2015 中编译和运行.或者,您可以将 Visual Studio 2013 和 2015 并排安装在您的计算机上.这样,您可以将 Visual Studio 2013 用于 MVC 4 项目,将 Visual Studio 2015 用于 MVC 5 及以上项目.
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:
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<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" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
We believe these are occurring because you are currently using MVC 4, and MVC 4 tooling is not included with Visual Studio 2015. Only MVC 5 and MVC 6 tooling is included. If you are in fact using MVC 5 and seeing these issues, please do let us know. You can confirm you are using MVC 4 by opening packages.config and scrolling to the entry for Microsoft.AspNet.Mvc. If the version listed starts with "4", this means you are using MVC 4.
Having said that, we appreciate your feedback and the investment you have made in MVC 4. Based on yours and other customers’ feedback, we are looking into the possibility of making MVC 4 tooling available for Visual Studio 2015. In the meantime, your project will compile and run in Visual Studio 2015 despite the tooling issues. Alternatively, you can keep both Visual Studio 2013 and 2015 installed on your machine side-by-side. That way, you can use Visual Studio 2013 for MVC 4 projects and Visual Studio 2015 for MVC 5 and above projects.
这篇关于无法识别 Visual Studio 2015 Razor View MVC 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!