ASP捆绑软件中的绝对URL [英] Absolute URL in ASP bundle

查看:110
本文介绍了ASP捆绑软件中的绝对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将jQuery库用于Google Maps,这取决于首先加载的Google脚本.我希望能够将两者都包括在内:

I use a jQuery library for Google Maps, and it depends on the Google scripts to be loaded first. I'd like to be able to include both in the bundle as such:

  bundles.Add(new ScriptBundle("myfoobundle").Include(
    "http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places",
    "~/scripts/jquery.fooplugin-{version}.js"
  ));

这似乎不起作用(抛出异常并抱怨第一个字符串).也许有人会说这应该行不通,因为绝对URL不会被缩小/捆绑.

This doesn't seem to work (throws an exception complaining about the first string). And one may say that this shouldn't work because that absolute URL is not meant to be minified/bundled.

但是当前的方法很麻烦,因为我需要确保依赖关系正确,并且发生在不同的地方(捆绑代码中的问题占一半,视图中的另一半).

But the current approach is a hassle, as I need to ensure that the dependencies are correct, and that happens in different places (half the problem in the bundling code, the other half in the view).

最好有一个如上所述的1步解决方案.在这方面我有什么选择吗?

Would be nice to have a 1-step solution as above. Do I have any options in this regard?

更新:

要解决有关使用CDN作为解决方案的评论:如果我指定bundles.UseCdn = true,则它无效,并且仍然会出现异常The URL 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' is not valid. Only application relative URLs (~/url) are allowed.另外,我不确定这样做的初衷是什么,因为我已经使用了jQuery等CDN支持,所以不确定如何与我的用例冲突.

To address the comments regarding using a CDN as a solution: if I specify bundles.UseCdn = true it has no effect, and I still get the exception The URL 'http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places' is not valid. Only application relative URLs (~/url) are allowed. Also I'm unsure what the implication of doing that is in the first place, because I already use CDN support for jQuery, etc., so unsure how that would conflict with my use case.

推荐答案

当前,您必须在捆绑包中包含要依赖的jquery的本地副本,否则就必须在管理脚本标签时提到.我们知道这种礼节性管理问题,它属于资产管理类别,我们正在使用 codeplex上的工作项目进行跟踪

Currently you would have to include a local copy of the jquery that you are depending on inside of the bundle, or you would have to manage the script tags as you mention. We are aware of this kind of depedency management issue and it falls under the category of asset management which we are tracking with this work item on codeplex

这篇关于ASP捆绑软件中的绝对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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