Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 本地脚本包呈现,但CDN包不会呈现_C#_Asp.net Mvc_Bundles - Fatal编程技术网

C# 本地脚本包呈现,但CDN包不会呈现

C# 本地脚本包呈现,但CDN包不会呈现,c#,asp.net-mvc,bundles,C#,Asp.net Mvc,Bundles,因此,对于脚本/样式包,我有: @Scripts.Render("~/bundles/jquery") @Styles.Render("~/Content/css") 捆绑包配置非常基本: bundles.UseCdn = true; bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/css/icomoon.css", "~/Content/bootstrap.css", "~/C

因此,对于脚本/样式包,我有:

@Scripts.Render("~/bundles/jquery")    
@Styles.Render("~/Content/css")
捆绑包配置非常基本:

bundles.UseCdn = true;

bundles.Add(new StyleBundle("~/Content/css").Include(
    "~/Content/css/icomoon.css",
    "~/Content/bootstrap.css",
    "~/Content/bootstrap-theme.css",
    "~/Content/toastr.css",
    "~/Content/custom.css"));

bundles.Add(new ScriptBundle("~/bundles/jquery", "//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"));
本地包可以工作,但CDN包不能。调试模式和发布模式似乎没有区别:在这两种情况下,jquery捆绑包只会在输出中产生一个空行


如何解决此问题?

使用BundleTable.EnableOptimizations=true;这将使绑定和缩小与您的调试模式无关。

挑剔的问题:如果这是由调试模式决定的,为什么关闭调试模式没有帮助?如果您只是参考,则不包括min.js。js版本MVC将在发布时为您进行缩小,并在调试模式下使用常规版本。您不需要明确地引用min.js。如果启用了优化,则无论您的调试模式如何,它都将进行缩小。请尝试使用ScriptBundle的重载方法,并将cdnPath作为第二个参数