ASP.NET/MVC 4在64位IIS 7.5服务器上捆绑和缩小404问题

Dus*_*tin 7 asp.net asp.net-mvc asp.net-mvc-4 asp.net-4.5 bundling-and-minification

我们最近将我们的项目从MVC 3升级到MVC 4.我们的目标是.NET 4.0框架,由于我们必须包含一些参考,我们的Web应用程序是32位的.

我们遇到的问题是我们将捆绑/缩小从Chirpy转换为内置的ASP.NET捆绑.该站点在32位服务器上运行,包括仅运行.NET 4.0的Windows Server 2003/IIS 6和2008/IIS 7.5以及我们的64位开发计算机.捆绑/缩小在上述所有方面都能正常工作.

在仅安装了.NET 4.0的64位Windows 2008/IIS 7.5服务器上,捆绑不起作用.生成的脚本和样式都会出现404错误.

如果我们在64位服务器上安装.NET 4.5,它可以正常工作.我们对此感到困惑,因为有些服务器在没有.NET 4.5的情况下工作,而这一点需要它.最重要的是,Windows Server 2003/64位与.NET 4.5不兼容,因此如果这也存在问题,则此修复程序将不起作用.

奇怪的是,针对.NET 4.0构建x86的示例MVC 4示例互联网应用程序在问题服务器上只有4.0就可以正常工作.除了unity,logging,elmah和dot less配置之外,web.config完全相同.

任何有关这方面的帮助将非常感激.

这是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"));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我们在布局中引用包的方式:

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

编辑:回应/更新

Dus*_*tin 0

该问题似乎与我们用于该服务器的 VM 上的 .NET 4.0 安装有关。创建两个新的 VM(均为 Windows 2008 64 位,一个标准,一个企业)并安装干净的 .NET 4.0 后,捆绑在这两个虚拟机上运行良好。感谢您的所有帮助。

  • 对于任何其他遇到此问题的人,我通过在 web.config &lt;system.webserver&gt; &lt;modules&gt; 部分添加一个条目来添加 BundleModule 来解决我的问题版本: &lt;remove name="BundleModule" /&gt; &lt;add name =“BundleModule”类型=“System.Web.Optimization.BundleModule”/&gt; (2认同)