How can we use css files in mvc application?

 Posted by Kmandapalli on 2/21/2014 | Category: ASP.NET MVC Interview questions | Views: 1689 | Points: 40
Answer:

Normally, I would put most of general layout related css into content/style.css

If you use theme, then put it into content/theme/{themename}/style.css
If you create custom html control, i would try to create another css file for control and put it under content/control.css
In most of time, jquery is used in the asp.net MVC, so it make sense to put it's css in Script/jquery/{pluginName}/xxx.css
There could be more, but that's what's in my head now.

Splitting the css into multiple files is a good thing from a maintenace point of view. It makes it easier to work with and apply changes. However, multiple files can have an impact on application performance as the browser has to download each file individually. You can haev the best of both worlds though.

The technique that is recommended is to bundle all your html files for deployment so that it is served as 1 single file. The nice thing about this approach is that it lets you develop with multiple files, giving you ease of use. But get on the fly css file combination so that your browser only has to download one file.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response