Styles.Render does not load CSS files

When trying to use Bundles in an MVC5 application. CSS files do not load, when I check the source code, I see the following link in HTML:

<link href="/Content/css" rel="stylesheet"/>

Why is this not working as I expect? I tried using different virtual paths but this does not work.

File My BundleConfig.cs:

using System.Web;
using System.Web.Optimization;

namespace Navi
{
    public class BundleConfig
    {
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new StyleBundle("~/Content/css").Include(
                "~/Content/bootstrap.css",
                "~/Content/site.css"));
        }
    }
}

Then in my _Layout.cshtml I have the following:

@Styles.Render("~/Content/css")
+4
source share
2 answers

My problem here is that I need to add the following to the global.asax file:

BundleConfig.RegisterBundles(BundleTable.Bundles);

It also required me to include: using System.Web.Optimization;

+9
source

You cannot use a package name that is the outline of a folder that already exists in the solution. eg,("~/styles/css")

+2
source

All Articles