问题
In Visual Studio 2010 Ultimate, MVC3, razor engine, _Layout.cshtml. If I reference CSS like this :
<link href="@Url.Content("/Content/Site.css")" rel="stylesheet" type="text/css" />
than intellisense don't work for css classes! example :
<div class="<---- IntelliSense don't fire
But if i reference CSS like this :
<link href="/content/Site.css" rel="Stylesheet" type="text/css" />
than IntelliSense work.
Any help?
回答1:
Well, the "why" is simple: Visual Studio does not execute the call to Url.Content when discovering the CSS files. VS executes javascript when evaluating JS expressions, but not for discovering files.
You are probably wondering how to get it to work...
Well, there doesn't really seem to be a good way, as of yet. However, I cover one of the options (centered around JavaScript) on my blog:
http://otac0n.com/blog/2011/09/01/getting-javascript-intellisense-in-mvc-razor-views.html
This technique should work for CSS as well.
来源:https://stackoverflow.com/questions/7767700/asp-net-mvc3-intellisense-dont-fire-for-css-classes