如何强制 ASP.NET Ajax 使用 FS 中的脚本而不是 WebResource.axd,或者减少其 HTTP 请求?

发布于 2024-07-08 16:08:34 字数 801 浏览 7 评论 0原文

这是一个我还没有找到答案的问题。

我在几个页面上使用 ASP.NET ajax 控件工具包控件,这些控件本质上是希望通过 WebResource.axd 加载脚本资源。 对于某些应用程序来说,这一切都很好,但每次调用 WebResource.axd 都需要一个 HTTP 请求。 大多数页面将从 WebResource.axd 中提取至少 3 或 4 个资源,因此每个页面都会发出这么多 HTTP 请求。

由于过多的 HTTP 请求会对性能和用户对性能的感知产生负面影响,因此如果可能的话,我想将其减少到 1 个 HTTP 请求。

如果我可以从 AXD 中提取脚本或将 asp.net ajax 配置为使用脚本而不是 WebResource,那就太好了。

有谁知道我如何在使用 asp.net ajax 时实现最终目标? (此时另一个 JS AJAX 框架不是一个选择。)

编辑:找到解决方案。 这家伙永远很狡猾,如果我们见面的话,我会欠他很多顿饭/啤酒。 http://www.codeproject.com/KB/aspnet/fastload.aspx

编辑:找到了另一个解决方案 - 显然 MS 允许您下载脚本而不包括资源库.dll 您所需要做的就是将它们包含在项目中并在脚本管理器上设置 ScriptPath。

Here is a hum-dinger of a problem that I have not found an answer for.

I am using the ASP.NET ajax control toolkit controls on a few pages, which by nature want to load script resources via WebResource.axd. This is all well and good for some applications, but each call to WebResource.axd requires an HTTP request. Most pages will pull at least 3 or 4 resources from the WebResource.axd, so this many HTTP requests are issued for each page.

Since having too many HTTP requests will negatively impact performance and user perceptions of performance, I would like to trim that down to 1 HTTP request, if possible.

If I could extract the script from the AXD or configure asp.net ajax to use a script instead of the WebResource, it would really be sweet.

Does anyone know how I can go about accomplishing the end goal while using asp.net ajax? (At this moment another JS AJAX framework is not an option.)

EDIT: Found the solution. This guy is eternally crafty and I will owe him many meals/beer should we ever meet. http://www.codeproject.com/KB/aspnet/fastload.aspx

EDIT: Found another solution -- apparently MS allows you to download the scripts without including the resource dll. All you need to do is include them in the project and set the ScriptPath on the Script Manager.

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

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

发布评论

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

评论(1

欢烬 2024-07-15 16:08:34

简单的方法:定义适当的 HTTP 缓存标头。 用户代理将根据它们对同一资源的多个请求进行排序,并且您不必在服务器端解决该问题。

The easy route: Define proper HTTP caching headers. The user agent will sort out multiple requests to the same resource based on them, and you don't have to hack around the problem on the server side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文