ASP MVC在调试模式下捆绑后,并非所有文件都可用

时间:2013-12-19 13:32:46

标签: asp.net asp.net-mvc bundle

我有一个包

        public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.IgnoreList.Clear();
        AddDefaultIgnorePatterns(bundles.IgnoreList);

        bundles.Add(new ScriptBundle("~/bundles/js/allscripts.js").Include(
                    MobileConsts.MobileJsPath + "third-party/jquery/jquery-1.10.2.js",
                    MobileConsts.MobileJsPath + "third-party/plupload/gears_init.js",
                    MobileConsts.MobileJsPath + "third-party/plupload/browserplus-min.js",
                    MobileConsts.MobileJsPath + "third-party/plupload/plupload.full.min.js",
                    MobileConsts.MobileJsPath + "Namespace.js",
                    MobileConsts.MobileJsPath + "Init.js",
                    MobileConsts.MobileJsPath + "Utils.js",
                    MobileConsts.MobileJsPath + "AjaxHelper.js",
                    MobileConsts.MobileJsPath + "HistoryApi.js",
                    MobileConsts.MobileJsPath + "GoToDesktopSite.js",
                    MobileConsts.MobileJsPath + "DiMenu.js",
                    MobileConsts.MobileJsPath + "Controls/AjaxPreloader.js",
                    MobileConsts.MobileJsPath + "Controls/Link.js",
                    MobileConsts.MobileJsPath + "Controls/SelectBox.js",
                    MobileConsts.MobileJsPath + "Controls/DateBox.js",
                    MobileConsts.MobileJsPath + "Controls/FormSubmit.js",
                    MobileConsts.MobileJsPath + "Controls/Tabs.js",
                    MobileConsts.MobileJsPath + "UserInfo.js",
                    MobileConsts.MobileJsPath + "SubscribeButton.js",
                    MobileConsts.MobileJsPath + "UploadCommentImage.js",
                    MobileConsts.MobileJsPath + "ConfirmButton.js",
                    MobileConsts.MobileJsPath + "ReportComments.js",
                    MobileConsts.MobileJsPath + "EditComments.js",
                    MobileConsts.MobileJsPath + "AddComment.js"
                    ));

        bundles.Add(new StyleBundle("~/bundles/css/allcss.css").Include(
                    MobileConsts.MobileCssPath + "borssnack.css",
                    MobileConsts.MobileCssPath + "fonts.css",
                    MobileConsts.MobileCssPath + "icons.css",
                    MobileConsts.MobileCssPath + "components/radio-checkbox.css",
                    MobileConsts.MobileCssPath + "components/date-box.css",
                    MobileConsts.MobileCssPath + "select-box.css"/*,
                    MobileConsts.MobileCssPath + "reset.css"*/));

        bundles.Add(new ScriptBundle("~/bundles/js/menu.js").IncludeDirectory(SiteSettings.Instance.MobileDiVirtualDirectoryPath, SiteSettings.Instance.MobileDiseMenuJsFile));
        bundles.Add(new StyleBundle("~/bundles/css/menu.css").IncludeDirectory(SiteSettings.Instance.MobileDiVirtualDirectoryPath, SiteSettings.Instance.MobileDiseMenuCssFile));
    }

    private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
    {
        if (ignoreList == null)
            throw new ArgumentNullException("ignoreList");
        ignoreList.Ignore("*.intellisense.js", OptimizationMode.Always);
        ignoreList.Ignore("*-vsdoc.js", OptimizationMode.Always);
        ignoreList.Ignore("*.debug.js", OptimizationMode.Always);
        //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
        ignoreList.Ignore("*.min.css", OptimizationMode.Always);
    }

而且,在web.config中,我有:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">

何时

<compilation debug="false" targetFramework="4.0" />

一切正常,但

<compilation debug="true" targetFramework="4.0" />
HTML中的

一切正常:

<script src="/mobile/static/js/third-party/jquery/jquery-1.10.2.js"></script>
<script src="/mobile/static/js/third-party/plupload/gears_init.js"></script>
<script src="/mobile/static/js/third-party/plupload/browserplus-min.js"></script>
<script src="/mobile/static/js/third-party/plupload/plupload.full.min.js"></script>
<script src="/mobile/static/js/Namespace.js"></script>
<script src="/mobile/static/js/Init.js"></script>
<script src="/mobile/static/js/Utils.js"></script>
<script src="/mobile/static/js/AjaxHelper.js"></script>
<script src="/mobile/static/js/HistoryApi.js"></script>
<script src="/mobile/static/js/GoToDesktopSite.js"></script>
<script src="/mobile/static/js/DiMenu.js"></script>
<script src="/mobile/static/js/Controls/AjaxPreloader.js"></script>
<script src="/mobile/static/js/Controls/Link.js"></script>
<script src="/mobile/static/js/Controls/SelectBox.js"></script>
<script src="/mobile/static/js/Controls/DateBox.js"></script>
<script src="/mobile/static/js/Controls/FormSubmit.js"></script>
<script src="/mobile/static/js/Controls/Tabs.js"></script>
<script src="/mobile/static/js/UserInfo.js"></script>
<script src="/mobile/static/js/SubscribeButton.js"></script>
<script src="/mobile/static/js/UploadCommentImage.js"></script>
<script src="/mobile/static/js/ConfirmButton.js"></script>
<script src="/mobile/static/js/ReportComments.js"></script>
<script src="/mobile/static/js/EditComments.js"></script>
<script src="/mobile/static/js/AddComment.js"></script>

但有些脚本不可用,因为例如/mobile/static/js/Namespace.js返回404错误未找到。

css资源也出现同样的情况。所有文件都存在。

1 个答案:

答案 0 :(得分:0)

尝试在chrome开发人员工具栏上进行监控,看看浏览器实际上在寻找资源的地址......(抱歉我的英文不好)