通过 ScriptManager 启用和禁用 CDN

发布于 2024-09-28 20:25:17 字数 285 浏览 0 评论 0原文

我想使用 Microsoft 的 CDN 来托管我的 .NET 4.0 Web 应用程序的 AJAX 库。但是,我被要求在 CDN 不可用或开发人员想要在没有互联网的情况下进行本地开发时实施后备方案。在这些场景中,ScriptManager 应发送本地托管的 JavaScript 副本,而不是 CDN 副本。我知道我可以在脚本管理器中手动禁用 CDN,但这可能很乏味,并且可能会导致错过生产配置。

是否有更优雅的方法来使用 JavaScript 文件的本地副本,而无需通过 ScriptManager 在代码中的每个位置手动禁用 CDN?

I want to use the Microsoft's CDN for hosting the AJAX Library for my .NET 4.0 web application. However, I was asked to implement a fallback for when the CDN isn't available or when developers want to develop locally without internet. In these scenarios the ScriptManager should send the locally hosted copies rather than the CDN copies of the JavaScript. I know I can manually disable the CDN in the scriptmanager, but this can be tedious and potentially lead to missed configurations reaching production.

Is there a more elegant way to use a local copy of the JavaScript files without manually disabling CDN in every spot in code via ScriptManager?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海夜未眠 2024-10-05 20:25:17

取自 html5 样板

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>

Taken from html5 boiler plate

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文