Last post Sep 10, 2013 05:57 PM by bensgroi
Nov 10, 2012 05:48 AM|esassaman|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 06:06 AM|HostingASPNet|LINK
It seems as some path issue. You could check in the IIS error logs for mmore clues.
Nov 22, 2012 04:30 PM|esassaman|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 08:55 AM|bbroom|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 04:57 PM|esassaman|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 05:06 AM|bbroom|LINK
Nice one. Glad you got it sorted. Bundling and minification is a very handy feature.
Jul 23, 2013 01:44 PM|mklaene|LINK
Wow. I spent 5 hours on this searching and struggling with this... The solution above (adding the 'BundleModule' with the <add> worked for me. I would love to understand the reason why I needed this... Something with the latest ASP.NET 4.5 web forms template
it not right.
Thank you for this solution!
Jul 23, 2013 02:02 PM|esassaman|LINK
If I had to make a guess, it's probably my (and your) web host. Mine supports asp.net but NOT very well, this is one of a few config issues on their side I've had with them, so I wouldn't be surprised if it was yet another configuration issue. The same site
deployed to another web host (Arvixe) did not need that web.config change, it just works.
Sep 10, 2013 05:57 PM|bensgroi|LINK
I spent a while stuck on this also. Thanks!