1

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" /> 
5
  • 1
    Firstly, don't let your bundle name collide with real folders. In other words change your bundle name to something like ~/bundle/static/css/LoginPage in your BundleConfig.cs definition and in your Login.cshtml. Bundling really is a pain Commented May 17, 2017 at 4:37
  • Also can you confirm there are no 404 errors in your network tab. How do you know the CSS is blank? Are you using F12 tools to look at it? Commented May 17, 2017 at 4:39
  • Thank you! Yes, I am using chrome developer tools to inspect the bundle. I will try changing the path, as well as double-checking the network tab. Commented May 17, 2017 at 5:02
  • Good luck, It's really painful. Also be aware that when you're in debug mode it turns off bundling automatically. Which is what I found out when my site worked perfectly then when I published it it failed completely because bundling was incorrect. See her on how to force bundling on and off: stackoverflow.com/questions/16030905/… Commented May 17, 2017 at 5:58
  • changing the path to ~/bundles/css/LoginPage worked! Please respond as an answer and I'll mark it as the answer. Commented May 17, 2017 at 13:36

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! Doing this populated the style bundles, but then I ran into many 404s because of relative paths in the stylesheets. >_<. That made me realize my underlying problem wasn't in the bundling, though, but rather some middleware that was reading routes. The style bundles were slipping through the defined routes, and then the middleware was throwing an exception. Thanks for helping me think through this, though, and your answer is still the right one. Cheers!
Oh good! I actually still have a problem myself with relative paths in bootstrap - I can't use glyphicons.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.