08 Oct 2012
09 Oct 2012
Link to this post
What is the best practice for storing CSS and JS for MVC widgets?
For example I have all my MVC widgets under the /Mvc directory which then breaks down to Controllers, Models, Views
I want to use a new CSS or JS file for my widget. I am currently copying and pasting all the the CSS and JS content directly into my view's .cshtml which is not ideal at all.
Where should I store the CSS/JS files, and how would I link them from my view?
I was thinking something like this structure might work, where I would have a 'widgets' directory on the same level as the Mvc directory:
Or would it be better to create the css and js directories inside the actual view's directory?
Using that how would I link them from my view. I suppose I would need some sort of variable containing the site HTTP root like: