This project is read-only.

Links to static scripts in view folders?

May 10, 2013 at 1:31 AM
I am considering putting view specific scripts CSS side by side with the View files in our view folder, and will be modifying my Web.config file similar to this:

I would like some way to be able to link to those script files using T4MVC, similar to how it works for other static content and scripts? Is there some way to modify the configuration file for T4MVC to get this to work, or will I have to hack up the main script itself to enable this?

It is very convenient to put view specific JS files side by side with the views themselves, rather than using inline script code in the view files. It helps keep the code cleaner (no JS code to muddy the waters in the Razor files), as well as makes it possible to debug view specific Javascript within VS (not possible with script tags in a .cshtml file). And I really don't want to put them into the /Scripts directory, since that is really for site wide scripts and we could easily get naming conflicts.

May 10, 2013 at 1:36 AM
I suppose another alternative would be to create a special Javascript and CSS action invoker for the Controller class, as also suggested on Stack Overflow. The upside there is it would be easy to make a function to get to JS or CSS for a view easily just from the view name. The downside is loading those files requires a complete controller to be executed, which then reads the source file from disk and returns it. I assume the browser would cache the results, but if you can make it behave like a static request with some web.config file changes, it would be more efficient right?