Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET / MVC 4 bundling and minification 404 issues on 64-bit IIS 7.5 server

We recently upgraded our project from MVC 3 to MVC 4. We are targeting the .NET 4.0 framework, and our web app is 32-bit due to some references we have to include.

The problem we are having is that we converted our bundling / minification from Chirpy to the built-in ASP.NET bundling. The site runs with no problems on 32-bit servers, both Windows Server 2003/IIS 6 and 2008/IIS 7.5 running ONLY .NET 4.0, and our 64-bit development machines. The bundling / minification works fine on all of the above.

On a 64-bit Windows 2008 / IIS 7.5 server with ONLY .NET 4.0 installed, bundling does not work. We get 404 errors for both the generated scripts and styles.

If we install .NET 4.5 on the 64-bit server, it works fine. We are confused by this because some servers work without .NET 4.5, and this one requires it. On top of that, Windows Server 2003 / 64-bit is not compatible with .NET 4.5 so if that has an issue as well, this fix won't work.

The weird thing is, the sample MVC 4 sample internet app targeting .NET 4.0 built x86 works fine with just 4.0 on the problem server. The web.config is exactly the same except for unity, logging, elmah, and dot less configuration.

Any help with this would be much appreciated.

Here's the BundleConfig.cs:

using System.Web;
using System.Web.Optimization;

namespace WebApp
{
    public class BundleConfig
    {
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = false;

            // .debug.js, -vsdoc.js and .intellisense.js files 
            // are in BundleTable.Bundles.IgnoreList by default.
            // Clear out the list and add back the ones we want to ignore.
            // Don't add back .debug.js.
            bundles.IgnoreList.Clear();
            bundles.IgnoreList.Ignore("*-vsdoc.js");
            bundles.IgnoreList.Ignore("*intellisense.js");

            bundles.Add((new ScriptBundle("~/bundles/WebApp.Register1")).Include("~/Scripts/jquery.ba-tinypubsub.min.js",       
                                                                                 "~/Scripts/knockout-2.1.0.js",
                                                                                 "~/Scripts/WebApp/WebApp.Register.RegisterStudent.js",
                                                                                 "~/Scripts/WebApp/WebApp.Register.RegisterPresenter.js"));

            bundles.Add((new Bundle("~/bundles/WebApp.Register2")).Include("~/Scripts/WebApp/WebApp.Register.StudentSelect.js"));


            bundles.Add((new ScriptBundle("~/bundles/WebApp.View1")).Include("~/Scripts/jquery.ba-tinypubsub.min.js",
                                                                             "~/Scripts/WebApp/WebApp.View.ImagePresenter.js", 
                                                                             "~/Scripts/WebApp/WebApp.View.ImageResults.js"));

            bundles.Add((new Bundle("~/bundles/WebApp.View2")).Include("~/Scripts/WebApp/WebApp.View.StudentsSelect.js"));

            bundles.Add((new ScriptBundle("~/bundles/WebApp.Print1")).Include("~/Scripts/WebApp/WebApp.Print.SelectedIdArray.js",
                                                                              "~/Scripts/jquery.ba-tinypubsub.min.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.DocumentsSelect.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.DocumentsSelected.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.DocumentsPresenter.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.StudentsPresenter.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.PrinterSelected.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.OutputSummary.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.OutputPresenter.js",
                                                                              "~/Scripts/WebApp/WebApp.Print.NoStudentPresenter.js"));

            bundles.Add((new Bundle("~/bundles/WebApp.Print2")).Include("~/Scripts/WebApp/WebApp.Print.StudentsSelect.js",
                                                                        "~/Scripts/WebApp/WebApp.Print.StudentsSelected.js"));

            bundles.Add((new ScriptBundle("~/bundles/WebApp.Main")).Include("~/Scripts/modernizr.custom.33607.js", 
                                                                            "~/Scripts/jquery-1.6.1.js",
                                                                            "~/Scripts/jquery-ui-1.8.10.custom.min.js",
                                                                            "~/Scripts/jquery-ui.min.js", 
                                                                            "~/Scripts/json.js",
                                                                            "~/Scripts/jquery.validate.min.js", 
                                                                            "~/Scripts/jquery.marquee.js",
                                                                            "~/Scripts/YUI.js", 
                                                                            "~/Scripts/Common.SearchHighlight.js"));

            bundles.Add((new StyleBundle("~/bundles/Content/WebApp.Main")).Include("~/Content/jquery.marquee.min.css",
                                                                                      "~/Content/YUI.css", 
                                                                                      "~/Content/Site.css",
                                                                                      "~/Content/ui-lightness/jquery-ui-1.8.10.custom.css"));
        }
    }
}

Here's how we're referencing the bundles in our layout:

    @Scripts.Render("~/bundles/WebApp.Main")
    <link href="@Url.Content("~/Content/SiteLess.less")" rel="stylesheet" type="text/css"  />
    @Styles.Render("~/bundles/Content/WebApp.Main")
    ...

EDIT: Responses / updates

  • Yes, the Enabled 32-bit apps flag is set to True in the app pool.
  • The path to the request that gives the 404 looks like this http://xx.xx.xx.xxx/WebApp/bundles/WebApp.Main?v=03pBc7hdH1lHLtZGx-JMosNaLpMK7fcmI0uI6auknHw1
  • Windows event viewer shows nothing
  • It works after installing .NET 4.5, uninstalling it, then reinstalling .NET 4.0
  • It works on an enterprise 2008 64-bit Server. The problem server is standard edition. We are going to rebuild the VM to see if that fixes the issue.
like image 894
Dustin Avatar asked Feb 21 '13 23:02

Dustin


1 Answers

The environment where you initially experienced 404 issues likely did not have the extensionless URLs hotfix applied.

See http://support.microsoft.com/kb/980368

Coincidentally, your "clean .NET 4.0" install either was a version later than 4.0 (perhaps 4.5?) or you may have unknowingly applied the hotfix / update to enable support for extensionless URLs.

I ran into same problem in Windows Server 2008 boxes (Enterprise; both 32bit and 64bit), where the bundler was not failing at runtime (it was correctly creating bundles, and correctly rendering the bundle URL, like /app/bundles/my_script), but IIS was returning 404 for the bundle URL. I installed hotfix 980368 and the bundles starting working.

like image 124
nothingisnecessary Avatar answered Sep 27 '22 18:09

nothingisnecessary