0

I have the following code in Config.cs:

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-2.2.3.min.js",
                    "~/Scripts/jquery.validate.min.js",
                    "~/Scripts/jquery.validate.unobtrusive.min.js",
                    "~/Scripts/jquery.unobtrusive-ajax.min.js"
                    ));
        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/font-awesome.min.css",
                  "~/Content/css/site.css", 
                  "~/Content/css/ab-style.css"));

The styles are not rendering correctly and page is looking odd. But everything works fine when I set BundleTable.EnableOptimizations = false in config.cs. Does anybody have a clue as to why this is happening.

NOTE: There is no Debug= "true" in Web.config and there is no conflict of virtual path as there is no "~/bundles/jquery", "~/bundles/bootstrap" ... folders in my project.

Sujoy
  • 1,051
  • 13
  • 26
  • Possible duplicate of [MVC4 - Bundling does not work when optimizations are set to true](http://stackoverflow.com/questions/12240097/mvc4-bundling-does-not-work-when-optimizations-are-set-to-true) – jdphenix Sep 15 '16 at 04:42
  • Probably this question - this has bit me before, try `new StyleBundle("~Content/css/all.css").Include(...` – jdphenix Sep 15 '16 at 04:42

1 Answers1

3

Create your bundle in virtual folder.

  bundles.Add(new StyleBundle("~/Content/css/AllMyCss.css").Include(
              "~/Content/bootstrap.css",
              "~/Content/font-awesome.min.css",
              "~/Content/css/site.css", 
              "~/Content/css/ab-style.css"));

and use the following code to render a bundle

@Styles.Render("~/content/css/AllMyCss.css")
Sujoy
  • 1,051
  • 13
  • 26
Mannan Bahelim
  • 1,289
  • 1
  • 11
  • 31