Search code examples
c#asp.netasp.net-mvc-5owinbundling-and-minification

ASP.NET MVC Bundles for css are blank with OWIN


We have recently moved our ASP.NET 5.2.3 application to OWIN 3.0.1 and are having bundling issues. The *.js is bundling appropriately, but the *.css bundles are coming out blank.

Where can I look for more details from the bundling output to figure out what's happening?

Code structure


Login.cshtml

<head>
...
    @Html.RenderStyles("~/static/css/LoginPage")
...
</head>


BundleConfig.cs

using System.Web.Optimization;

namespace Foo.bar.Web.Bootstrapper {
  public class BundleConfig {
    public static void RegisterBundles(BundleCollection bundles) {
      bundles.UseCdn = true; //enable CDN support

      bundles
       .Add(new StyleBundle("~/static/css/LoginPage")
       .Include(
         "~/Static/css/login.css", 
         "~/Static/css/chosen.css")
       );
    }
  } 
}


Startup.cs

[assembly: OwinStartup(typeof(Startup))]
namespace Foo.Bar.Web.Bootstrapper {
    public class Startup {
        private IContainer container;
        public void Configuration(IAppBuilder app) {
            //Commenting/Uncommenting this makes no difference.
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }
}


Web.config

<modules runAllManagedModulesForAllRequests="true" />

Solution

  • First thing to to ensure is that your bundle name doesn't collide with real folders.

    In other words change your bundle name to something like ~/bundle/static/css/LoginPage

    in both your BundleConfig.cs definition and in your Login.cshtml