Saturday, November 2, 2013

Styles.Render versus Scripts.Render

@Styles.Render("~/Content/css")
&
@Scripts.Render("~/bundles/modernizr")

 
 
 
 

...will both go fishing in BundleConfig.cs in the App_Start folder of an ASP.NET Web API with MVC Visual Studio 2013 project. Where they will find...

 
 
 
 

bundles.Add(new StyleBundle("~/Content/css").Include(
   "~/Content/bootstrap.css",
   "~/Content/site.css"));

&
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
   "~/Scripts/modernizr-*"));

 
 
 
 

...respectively. It is important to note the difference in the HTML that Styles and Scripts spit up to the browser however. The stuff above gives us back...

 
 
 
 

<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

&
<script src="/Scripts/modernizr-2.6.2.js"></script>

 
 
 
 

...respectively.

No comments:

Post a Comment