Styles.Render in MVC4
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"));
A bit late to the party. But it seems like no one has mentioned
bundling & minification of StyleBundle
, so..
@Styles.Render("~/Content/css")
calls in Application_Start()
:
BundleConfig.RegisterBundles(BundleTable.Bundles);
which in turn calls
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/Site.css"));
}
RegisterBundles()
effectively combines & minifies bootstrap.css
& Site.css
into a single file,
<link href="/Content/css?v=omEnf6XKhDfHpwdllcEwzSIFQajQQLOQweh_aX9VVWY1" rel="stylesheet">
But..
<system.web>
<compilation debug="false" targetFramework="4.6.1" />
</system.web>
only when debug
is set to false
in Web.config
.
Otherwise bootstrap.css
& Site.css
will be served individually.
Not bundled, nor minified:
<link href="/Content/bootstrap.css" rel="stylesheet">
<link href="/Content/Site.css" rel="stylesheet">
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.