Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 09, 2013 09:06 AM by bbroom
Nov 10, 2012 09:48 AM|LINK
I need some pointers on how to diagnose this problem. I've got bundling and minification working just great on my local project, but when I copy the changes up to my web host, I just get a bunch of 404 errors trying to load those bundles. Both sites are
running identical code - one bundles fine, the other doesn't.
I have a BundleConfigs.cs in my App_Code directory that has for example:
Along with a few bundles.Add loading jquery etc. from the microsoft CDN.
I have a bundle.config for all my css files, with a styleBundle like:
<include path="~/Content/normalize.css" />
<include path="~/Content/main.css" />
<include path="~/Content/Site.css" />
In my global.aspx:
void Application_Start(object sender, EventArgs e)
In my site.master file in the <head>:
<webopt:BundleReference runat="server" Path="~/Content/css" />
In my default.aspx, I have a few Scripts.Render calls to load jquery etc. For example:
<%: Scripts.Render("~/bundles/default") %>
among others for jquery etc.
So everything seems correct (hopefully, this is my first time getting this to work) and in fact it DOES work like a charm on my local machine. I can turn debug off and notice on the Net panel in Firebug that it is most definitely not loading all the individual
css/js files but only a few bundles. Awesome!
However the site, with the same exact files, on my web host, fails. All the bundle loads result in 404 errors.
My guess is that this is maybe a directory permission problem on the host? I tried giving the anonymous user rights to write to various directories, but that didn't make a difference. Where are these actual bundles being stored on the web server to be served
up? I can't even begin to diagnose what is going wrong. I've looked very carefully at my local vs. host web.config looking for differences, and I can't spot anything obvious that has anything to do with bundling...
Anyone have any tips on how I can get this working or figure out why it is failing?
For now I've set BundleTable.EnableOptimizations = false in BundleConfig.cs to turn it all off, which works fine.
Nov 10, 2012 10:06 AM|LINK
It seems as some path issue. You could check in the IIS error logs for mmore clues.
Nov 22, 2012 08:30 PM|LINK
Hm nothing unusual in the event log, and I can see the paths much more easily in Firebug. I also tried creating my CSS bundles in my BundleConfig.cs file, like this:
Then reference them in my Site.master like:
<%: Styles.Render("~/content/css") %>
Then deleted my bundle.config. Again, this works great locally. For example I can see this in the load call in Firebug:
to load my bundled css file. Everything works fine locally.
But once again on my web host, I see the same exact URL being loaded but it fails with a 404. I even tried copying the entire site directly from my local machine to a new test site on the same web host, even the web.config (with one change, I set debug to
false). Even on my test site, it fails with an exact copy of the local site.
One difference I noted is that my host is running IIS7 and I'm running IIS8 on my dev machine. But from what I can tell there's no dependancy on IIS8 for bundling.
Unfortuantely I don't have any spare resources on a different web host I'm using to test on. I give up, bundling and minifcation is a bust for me. Such a cool idea, too :(
Jan 08, 2013 12:55 PM|LINK
Hi, I had a similar problem. The cause of mine was because I had removed the extensionless url handler which I needed to fix a different issue. If you have the following configuration in your web.config, try removing it:
Jan 08, 2013 08:57 PM|LINK
Finally found the answer here: http://stackoverflow.com/questions/11985431/why-is-my-css-bundling-not-working-with-a-bin-deployed-mvc4-app
For some reason my web host required
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
to be added to <modules> in <system.webServer>. Works like a charm now!
Jan 09, 2013 09:06 AM|LINK
Nice one. Glad you got it sorted. Bundling and minification is a very handy feature.