Vlad
Vlad

Reputation: 13

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(PageType), "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 :)

Upvotes: 1

Views: 667

Answers (1)

Mayo
Mayo

Reputation: 10782

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.

Upvotes: 1

Related Questions