开发者

Syntax highlighting of javascript file in an ASP.NET MVC view?

I have an ASP.NET MVC website which has a particular javascript file that needs to be run through the razor parser to render some @Url values. I have a controll开发者_开发百科er action, named public ActionResult Javascript() which simply returns javascript.cshtml as a partial view.

This all works fine, except that I lose syntax highlighting on the javascript. Is there a way to enable the razor parser on custom file extensions so I can rename my view to javascript.js and get that syntax highlighting back? Failing that, is there any other way I can force the view file to syntax-highlight as javascript when it's not wrapped in <script> tags?


There are better ways to reference controller actions from Javascript than baking in @Url.Action(...) calls. For example:

http://haacked.com/archive/2011/08/18/calling-asp-net-mvc-action-methods-from-javascript.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜