开发者

ASP.NET MVC2: How to include js script/resource files compiled into dll?

Is there a way in ASP.NET MVC to reference the resource files compiled into dll on the master/view? I'm looking for something similar to the ASP.NET way:

Page.ClientScript.GetWebResourceUrl(typeof(PageTyp开发者_如何学JAVAe), "ResourceName")

I'm converting a custom asp server control to MVC html helper. It relies on some js script and I'd hate to tell the client "oh, and just include this file as a script on this page".

ANY kind of help (or even thoughts) would be highly appreciated :)


You could have your controller return content that the browser believes is a JavaScript file. If all of the code to render the JavaScript file is in the controller then it would be rolled up into your app's DLL.

I've done this with CSS having the controller return a view that has a content type of "text/css". I'm sure the technique could be applied here as well.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜