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:
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.
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:
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 :(
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:
esassaman
Member
23 Points
42 Posts
Bundling not working when deployed to web host, works fine locally
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:
bundles.Add(new ScriptBundle("~/bundles/default").Include("~/default.js"));
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:
<styleBundle path="~/Content/css"> <include path="~/Content/normalize.css" /> <include path="~/Content/main.css" /> <include path="~/Content/Site.css" /> </styleBundle>In my global.aspx:
void Application_Start(object sender, EventArgs e) { BundleConfig.RegisterBundles(BundleTable.Bundles); }In my site.master file in the <head>:
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.
HostingASPNe...
All-Star
15876 Points
2974 Posts
Re: Bundling not working when deployed to web host, works fine locally
Nov 10, 2012 10:06 AM|LINK
Hello,
It seems as some path issue. You could check in the IIS error logs for mmore clues.
Regards
Free ASP.NET Examples and source code.
esassaman
Member
23 Points
42 Posts
Re: Bundling not working when deployed to web host, works fine locally
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:
bundles.Add(new StyleBundle("~/content/css") .Include("~/content/normalize.css") .Include("~/content/Site.css") .Include("~/content/main.css") );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:
http://localhost:51412/content/css?v=vRf7uWGqCEMFte9HidVAaGAuENKRTyrelGbjwd-8RXQ1
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 :(
bbroom
Member
4 Points
2 Posts
Re: Bundling not working when deployed to web host, works fine locally
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:
<handlers> <remove name="ExtensionlessUrl-ISAPI-4.0_32bit"/> <remove name="ExtensionlessUrl-ISAPI-4.0_64bit"/> <remove name="ExtensionlessUrl-Integrated-4.0"/> </handler>esassaman
Member
23 Points
42 Posts
Re: Bundling not working when deployed to web host, works fine locally
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
to be added to <modules> in <system.webServer>. Works like a charm now!
bbroom
Member
4 Points
2 Posts
Re: Bundling not working when deployed to web host, works fine locally
Jan 09, 2013 09:06 AM|LINK
Nice one. Glad you got it sorted. Bundling and minification is a very handy feature.