asp.net-mvc 如何为 Razor 视图引擎获取 IntelliSense
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3491456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get IntelliSense for Razor View Engine
提问by max
Just installed Microsoft Visual Web Developer 2010 and trying to create an MVC application with Razor View Engine.
刚刚安装了 Microsoft Visual Web Developer 2010 并尝试使用 Razor View Engine 创建一个 MVC 应用程序。
When opened a ".cshtml" file, I am not able to get colors for syntaxes in editor and also intellisense is not appearing. Is there any option I explicitly need to enable it?
打开“.cshtml”文件时,我无法在编辑器中获取语法的颜色,也没有出现智能感知。是否有任何我明确需要启用它的选项?
回答by Kris van der Mast
UPDATE:The Release Candidatefinally supports Razor IntelliSense.
Update2: The final release got announced hereand it also still supports Intellisense for Razor syntax. Woohoo!
更新:该候选发布版终于支持剃刀智能感知。
更新 2:这里宣布了最终版本,它仍然支持 Razor 语法的 Intellisense。呜呼!
Here's a screenshot of the new enhanced Intellisense and Razor syntax highlighting:
这是新增强的 Intellisense 和 Razor 语法突出显示的屏幕截图:
For a great overview/introduction to MVC3 and NuGet I suggest you take a look at this PDC10 video.
有关 MVC3 和 NuGet 的精彩概述/介绍,我建议您查看此PDC10 视频。
Previous Answer
上一个答案
No. It doesn't work yet with the current beta:
不。它不适用于当前的测试版:
Razor intellisense isn't in today's beta. We needed to do a little more testing (and bug fixing) before we were ready to distribute it broadly. It patches a few VS files and so we need to make sure it is 100% solid before giving it out broadly.
It will definitely be in the final release, though, and should be available for people to install in the next few weeks.
Thanks,
Scott
Razor 智能感知不在今天的测试版中。在我们准备好广泛分发它之前,我们需要做更多的测试(和错误修复)。它修补了一些 VS 文件,因此我们需要确保它是 100% 可靠的,然后再广泛分发。
不过,它肯定会出现在最终版本中,并且应该可以在接下来的几周内供人们安装。
谢谢,
斯科特
回答by Darin Dimitrov
You can get syntax highlighting by associating the .cshtml
extension with the HTML editor in the Visual Studio properties (this will highlight only HTML tags and not Razor syntax). IntelliSense doesn't work yet. Microsoft will release an extension to Visual Studio which will support it in a later version.
您可以通过将.cshtml
扩展与 Visual Studio 属性中的 HTML 编辑器相关联来获得语法突出显示(这将仅突出显示 HTML 标记而不是 Razor 语法)。IntelliSense 还不能工作。Microsoft 将发布 Visual Studio 的扩展,它将在更高版本中支持它。
.
.
回答by Buildstarted
You can install a visual studio extension to get highlighting but not intellisense. Razor Syntax Highlighter
您可以安装 Visual Studio 扩展来突出显示,但不能安装智能感知。Razor 语法荧光笔
回答by Naveen
ASP.NET MVC team has just released RC release for ASP.NET MVC 3 and it has intellisense for Razor engine. :)
ASP.NET MVC 团队刚刚发布了 ASP.NET MVC 3 的 RC 版本,并且它具有用于 Razor 引擎的智能感知。:)
Follow this link for more information:
点击此链接了解更多信息:
http://weblogs.asp.net/scottgu/archive/2010/11/09/annoucing-the-asp-net-mvc-3-release-candidate.aspx
回答by codingbadger
The intellisense and syntax highlighting does not work in the current version. It is due to be fixed for the final release though.
智能感知和语法突出显示在当前版本中不起作用。不过,它将在最终版本中修复。
Saw a demo from Scott Gu on Friday - the Razor View engine looks very cool.
周五看到 Scott Gu 的演示 - Razor View 引擎看起来非常酷。