Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styles.Render in MVC4

In a .NET MVC4 project how does @Styles.Render works?

I mean, in @Styles.Render("~/Content/css") which file is it calling?

I dont have a file or a folder called "css" inside my Content folder.

like image 896
Ricardo Polo Jaramillo Avatar asked Aug 19 '12 17:08

Ricardo Polo Jaramillo


People also ask

What is styles render in MVC?

It's calling the files included in that particular bundle which is declared inside the BundleConfig class in the App_Start folder. In that particular case The call to @Styles. Render("~/Content/css") is calling "~/Content/site.

What does scripts render do?

Render generates multiple script tags for each item in the bundle EnableOptimizations is set to false. When optimizations are enabled, Render generates a single script tag to a version-stamped URL which represents the entire bundle.


2 Answers

It's calling the files included in that particular bundle which is declared inside the BundleConfig class in the App_Start folder.

In that particular case The call to @Styles.Render("~/Content/css") is calling "~/Content/site.css".

bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css")); 
like image 190
NunoCarmo Avatar answered Sep 20 '22 18:09

NunoCarmo


Watch out for case sensitivity. If you have a file

/Content/bootstrap.css

and you redirect in your Bundle.config to

.Include("~/Content/Bootstrap.css")

it will not load the css.

like image 24
linktoemi Avatar answered Sep 19 '22 18:09

linktoemi