Optimized bundles returning 404 when requesting from the website
Asked Answered
M

1

6

I'm having this weird problem when I set:

BundleTable.EnableOptimizations = true;

When I try to open my website it just won't load, when I open Chrome's console I see the following message:

GET /localhost/bundles/scripts/angularjs/commonmodules?v=13-uWpwzN3U6kiHVssXRdpywHxrn09twvYKwoDVN3SU1 404 (Not Found)

However, if I try to open the link shown on chrome's console, it loads just fine, in other words, the link is found when I try to open it directly, but the server (IIS 7.5) returns a 404 when a page tries to link it through a tag.

Have anyone been through such a weird behavior?

The virtual paths for my bundles do not map for any existing file or directory, I include them using the following code:

var myBundle= new ScriptBundle("~/bundles/scripts/angularjs/bootstrapping");
bootstrapping.Include("~/app/app.js")
    .Include("~/app/config.js")
    .Include("~/app/config.exceptionHandler.js")
    .Include("~/app/config.route.js");
bundles.Add(bootstrapping);

And I already tried to add the following lines on web.config's system.webServer:

<modules runAllManagedModulesForAllRequests="true">
    <remove name="BundleModule" />
    <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>

I'm not sure if this may be related, but I'm using Umbraco v7 on this website, and this only happens if I set EnableOptimizations to "true".

Malenamalet answered 14/4, 2014 at 3:29 Comment(0)
K
16

If I remember correctly it's umbraco config related.

Locate the key umbracoReservedPaths (in appSettings) in your web.config and add the path to bundles there, like so:

<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundles/"/>
Kingbolt answered 21/4, 2014 at 7:55 Comment(3)
thank you so much! adding "~/bundles/" and "~/app/" to umbracoReservedPaths did the job!Malenamalet
OMG - Three years, I have been trying to find this out. This works!!! I am currently using v4.7, v7.5, and v7.6.3. (+1)Grate
Adding my bundling paths in umbracoReservedPaths, fixed this for me. Thanks!Ernst

© 2022 - 2024 — McMap. All rights reserved.