0

I have an MVC 5 application.

I have this code in _Layout.cshtml

<head>
   ......
   @Styles.Render("~/Content/estilos")

   @RenderSection("styles", required: false)
</head>

I have this other code in the view:

@section styles
{
    @Styles.Render("~/Content/dataTables")
}

On the other hand, I have this in BundleConfig.cs file:

bundles.Add(new StyleBundle("~/Content/estilos").Include(
                      "~/Content/style.css",
                      "~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/dataTables").Include(
                      "~/Content/DataTables/css/dataTables.bootstrap4.css",
                      "~/Content/DataTables/css/fixedColumns.bootstrap4.css"));

With respect to files, these are present:

~/Content/site,css
~/Content/style.css
~/Content/DataTables/css/dataTables.bootstrap4.css
~/Content/DataTables/css/dataTables.bootstrap4.min.css
~/Content/DataTables/css/fixedColumns.bootstrap4.css
~/Content/DataTables/css/fixedColumns.bootstrap4.min.css

When I deployed the site, and set "debug = false" in "compilation debug="false" targetFramework="4.7.2" setting in web.config, I realized that only "estilos" bundle is loaded. "dataTables" bundle is missing.

When I set "debug = true", all CSS files are loaded.

What may be happening here?

Regards Jaime

jstuardo
  • 3,901
  • 14
  • 61
  • 136
  • Finally.. the problem was because the name of the bundle was the same as the physical path the dataTable css were in. – jstuardo Nov 07 '18 at 19:23

1 Answers1

0

You should avoid using existing directory paths as bundle name (directory names are case-insensitive as in Windows environment). Just rename with other name that not exist as physical directory path and the bundling should work:

bundles.Add(new StyleBundle("~/Content/tables").Include(
                      "~/Content/DataTables/css/dataTables.bootstrap4.css",
                      "~/Content/DataTables/css/fixedColumns.bootstrap4.css"));

Razor View

@section styles
{
    @Styles.Render("~/Content/tables")
}

Related issue:

Proper bundling of DataTables in ASP.net MVC

Tetsuya Yamamoto
  • 24,297
  • 8
  • 39
  • 61