1

I'm using ASP.NET MVC and my application is hosted in a local IIS. Everything was working fine. However, things start going weird when one of my colleagues downloaded a copy of the project from TFS Server and tried to set it up. CSS and JS are not being loaded.

When I browsed to these links via the page source code, I got empty files. It seems that the files are empty, but they are not.

   <link href="/Content/bootstrap.css" rel="stylesheet"/>
   <script src="/Scripts/modernizr-2.6.2.js"></script>

Here is my bundle configuration.

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

Many answers here in SO are suggesting to disable debug via web.config, but I need to debug.

EDIT: It must be related with IIS configuration, because I changed from Local IIS to ISS Express and everything worked fine.

Luis Teijon
  • 4,769
  • 7
  • 36
  • 57

2 Answers2

2

As a temporary solution, I changed from Local IIS to ISS Express and everything was loaded as expected.

Update: I found the solution by enabling Static Content in the IIS.

Luis Teijon
  • 4,769
  • 7
  • 36
  • 57
0

To enable bundling and minification, set the debug value to "false". You can override the Web.config setting with the EnableOptimizations property on the BundleTable class.

<system.web>
    <compilation debug="true" />
    <!-- Lines removed for clarity. -->
</system.web>

Unless EnableOptimizations is true or the debug attribute in the compilation Element in the Web.config file is set to false, files will not be bundled or minified. Additionally, the .min version of files will not be used, the full debug versions will be selected.

public static void RegisterBundles(BundleCollection bundles)
{
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                "~/Scripts/modernizr-*"));
               .Include("~/Content/bootstrap.css");

       BundleTable.EnableOptimizations = true;
}
Lorena Pita
  • 1,366
  • 1
  • 17
  • 20