在MVC脚本捆绑使用CDN。我在想什么? [英] Using CDN in MVC script bundle. What am I missing?

查看:356
本文介绍了在MVC脚本捆绑使用CDN。我在想什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个CDN装载jQuery的。我已阅读文章,这似乎像它应该是非常简单的。

I am trying to use a CDN for loading jquery. I have read this article and this seems like it should be very straightforward.

我的脚本包定义如下。

bundles.UseCdn = true;
bundles.Add(new ScriptBundle("~/bundles/jquery", "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js").Include(
                        "~/Scripts/jquery-{version}.js"));

我包括在页面上,如下所示:

I am including it on the page as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    @RenderBody()

    @Scripts.Render("~/bundles/jquery")
    @RenderSection("scripts", required: false)
</body>
</html>

但是,当我看萤火似乎jQuery是正在从本地主机加载。

But when I look at firebug it seems that jquery is being loaded from localhost.

我既realease和调试试图建立/。
我在想什么?我想,这应该是很简单的。谢谢你。

I have tried with both realease and debug builds/. What am I missing? I think this should be quite straightforward. Thanks.

推荐答案

运行你的调试=false的模式应用程序或使用 BundleTable。 EnableOptimizations = TRUE;

Run your application in debug="false" mode or use BundleTable.EnableOptimizations = true;

这篇关于在MVC脚本捆绑使用CDN。我在想什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆