Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StyleBundle being rendered as ScriptBundle

My CSS StyleBundle is being rendered in a <script> tag instead of a <link> tag.

This has me scratching my head. I keep looking for my typo but everything looks fine.

This is my BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                "~/Scripts/jquery-{version}.js"));

    bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
    "~/Scripts/jquery-ui-{version}.js"));

    bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                "~/Scripts/jquery.validate*"));

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

    bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
              "~/Scripts/bootstrap.js",
              "~/Scripts/respond.js"));

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


    bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
              "~/Content/themes/base/all.css"));

    BundleTable.EnableOptimizations = false;
}

This is the head from my _Layout.cshtml:

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/Content/themes/base/css")
    @RenderSection("head", required: false)
</head>

And this is how the HTML is rendered:

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home Page - My ASP.NET Application</title>
    <link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>

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

    <script src="/Content/themes/base/all.css"></script>


</head>

The layout is a bit off so something looks like it is up but I can't see what. Why isn't it rendering the css file in a <link> tag?

like image 389
Guerrilla Avatar asked Nov 06 '14 23:11

Guerrilla


1 Answers

In your layout, this line:

@Scripts.Render("~/Content/themes/base/css")

Should be:

@Styles.Render("~/Content/themes/base/css")
like image 200
DavidG Avatar answered Sep 25 '22 18:09

DavidG