asp.net-mvcbundle

BundleConfig returns 302 / 404


I can't for the life of me understand why my project developed this issue.

I am using the .Net Framework 4.7.1. My bundle is defined as follows:

var styleBundle = new StyleBundle("~/assets/sass/aaaa").Include(
    "~/assets/sass/main.css"
);

// This transform adds a randomized version number to the end of the bundle name
styleBundle.Transforms.Add(new FileHashVersionBundleTransform());

bundles.Add(styleBundle);

And in the Layout page:

@System.Web.Optimization.Styles.Render("~/assets/sass/aaaa")

The request results in a 302 that is then redirect to my 404 error page.

What could I possibly be doing wrong?

A previous version (one week old) of my codebase running on a separate Application Pool works without issues, but in the main branch all my bundles no longer work.

EDIT: I already browsed the other questions on this same topic on this site and elsewhere. I attempted all the suggested changes to the Application Pool and Web.config, with no luck whatsoever.


Solution

  • The solution to this problem is Sitecore-specific. The /assets path was not included in the IgnoreUrlPrefixes, a Sitecore configuration field that is used to single out URL prefixes that should be exception to the default Sitecore routing.

    This was causing my bundling to fail.