Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style and script management in Asp.Net MVC

I'm right now using asp.net mvc 2.0 in my projects. I like the way asp.net mvc is designed and works, but i feel it lack good support for applications with a large amount of styles and scripts.

In order to isolate different parts of an application i use areas, child only actions and partials. I would like a standard way to separate my scripts and styles too, i.e. put my script and style files in an area (not in the script and content folder on the root) and good way of including them on pages where they belong.

Right now I'm using a content place holder on every page in which I can include any script and styles for that action, but I would like a way of including a script from e.g. child only action.

What are your thoughts on this, how do you manage your script and style files, are there any patterns or best practices?

like image 571
Gustav Gahm Avatar asked Dec 02 '25 08:12

Gustav Gahm


1 Answers

You could use Chirpy (ehem): http://chirpy.codeplex.com/

Or SquishIt: https://github.com/jetheredge/SquishIt

Or create a controller that handles requests for js/css files: http://www.weirdlover.com/2010/05/10/zcontroller-asp-net-mvc-controller-fo-your-scripts-styles-images/

Or create an IHttpModule for handling js/css requests: How2: what event to hook in HttpModule for putting js links into head element

Not sure if that's what you're looking for. But it's all I've got.

like image 51
Evan Nagle Avatar answered Dec 03 '25 21:12

Evan Nagle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!