【问题标题】:MVC CDN Bundle not using local copy in debugMVC CDN Bundle 在调试中未使用本地副本
【发布时间】:2013-07-06 02:38:52
【问题描述】:

我阅读了许多关于使用 CDN 托管 jQuery 的 MVC 博客。他们都说 “在上面的代码中,将在发布模式下从 CDN 请求 jQuery,并且在调试模式下将在本地获取 jQuery 的调试版本。” (例如http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

但是,当我编写这段代码时:

// Enable CDN support
bundles.UseCdn = true;   

//add link to jquery on the CDN
const string jqueryCdnPath = "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
bundles.Add(new ScriptBundle("~/bundles/jquery",jqueryCdnPath)
                        .Include("~/Scripts/jquery-{version}.js"));

...并调试我的 MVC 应用程序,正在调用 google api(不是我在调试时所期望的本地副本。

我的构建肯定是调试的,在我的 Web.config 中,我有这个:

<compilation debug="true" targetFramework="4.0">

有谁知道为什么仍在进行调用以从 google CDN 获取 jquery?

【问题讨论】:

    标签: asp.net-mvc debugging query-optimization cdn


    【解决方案1】:

    好的,我已经找到了答案。

    我已经从我的代码中删除了这一行。

    BundleTable.EnableOptimizations = true
    

    现在在我的 web.config 中使用 debug=false 运行时,捆绑已启用并使用 Cdn。

    使用 EnableOptimizations = false 将调试设置回 debug=false 的一个意外副作用(至少对我来说是出乎意料的)是捆绑也被忽略了。如果能够在调试模式下启用优化但禁用 CDN 请求,那就太好了。如果可以的话,有人吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-16
      • 2013-07-06
      • 2021-06-20
      • 2011-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多