2

Considering this folder structure:

Content
     style1.css
     style2.css
     CssFolder1
         style3.css
         style4.css
         style5.css
         style6.css

In the application, I want to include style1.css, style2.css, style3.css and style4.css.

I am doing this:

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/styles/main").Include("~/Content/style1.css",   "~/Content/style2.css"));
        bundles.Add(new StyleBundle("~/styles/custom").Include("~/Content/CssFolder1/style3.css","~/Content/CssFolder1/style4.css"));
    }
}

And in _Layout.cshtml I render it like this:

@Styles.Render("~/styles/main", "~/styles/custom")

Only style1.css and style2.css are loaded. How to correctly load style3.css and style4.css?

LE: Content is a folder from the solution, all files within that folder are added to the solution.

gigi
  • 3,846
  • 7
  • 37
  • 50
  • Your code looks fine. Which webserver are you using VS Dev server, IIS express, IIS? Are you sure that the files are there? What happens if you include them manually with ``? – nemesv Sep 02 '12 at 13:53
  • I already tried that, if i include them manually they are loaded. I am using VS Dev Server. – gigi Sep 02 '12 at 13:58
  • Are you using forms authentication? If so, have you allowed public access to styles/custom ? – Paul Fleming Sep 02 '12 at 14:55

1 Answers1

1

All files need to be added to the project in the Visual Studio solution window. Right click on the css folder and click add existing item. Navigate to the styles3.css and add it that way.

George Stocker
  • 57,289
  • 29
  • 176
  • 237