如何使用.NET脚本回调模型发送多个同时回调? [英] How to send multiple simultaneous callbacks with .NET script callback model?

查看:72
本文介绍了如何使用.NET脚本回调模型发送多个同时回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您阅读本文。



我正在开发一个.NET 2.0网站,该网站使用脚本回调AJAX方法为前端提供动力。



我的情况是客户端上的一个事件需要更新网页中的多个面板。首先,我将其设置为发送一个请求,该请求由服务器端代码的多个部分解释,每个部分都附加到序列化并发送回客户端的响应。最终结果是客户端立即收到响应的所有部分,并将响应拆分为相关部分以更新页面的不同部分。



我想要什么现在做的是发出多个同时的请求,以便响应的每个部分单独发送,页面更新,而不是一次更新。



我知道我有一个选项可以在客户端对请求进行排队,并在上一个响应进入时发送下一个请求,但我希望立即解除所有请求,并在返回时处理响应。



每当我尝试发送多个请求时,除了最后一个请求之外的所有请求似乎都被删除了,我只得到最后一个响应。我想要了解的是为什么会发生这种情况。在我看来,有以下几种可能:



- 服务器端逻辑一次只能处理一个请求,并丢弃所有先前的请求;

- 客户端逻辑在发出新请求时"忘记"所有先前的请求,因此只响应它理解的那个(最后一个发送的请求)。

< br>


我会非常感谢有关为什么会发生这种情况的任何反馈,以及我可以做些什么来解决这个问题。我已经考虑在我的应用程序中使用IFrame,所有引用页面都有自己的请求/响应处理程序,但我宁愿不介入它,因为它会显着改变到目前为止使用的开发模型。



任何帮助非常感谢。



Tom


Hi, thanks for reading this.

I'm developing a website in .NET 2.0 that uses the script callback AJAX method to power the front end.

I have a situation where one event on the client needs to update multiple panels in the web page. At first I set this up so that one request is sent which is interpreted by multiple parts of the server-side code, which each append to the response that is serialized and sent back to the client. The end result of this is that the client receives all parts of the response at once and splits the response into the relevant pieces to update different parts of the page.

What I want to do now is make multiple simultenous requests, so that each part of the response is sent separately and the page updates in pieces, rather than all at once.

I know that I have an option to queue requests at the client, and send the next request when the previous response comes in, but I would prefer to fire all requests off at once and handle responses as they are returned.

Whenever I try to send multiple requests, all but the last request appear to get dropped, and I only get the last response. What I am trying to understand is why this is happening. As I see it, there are the following possibilities:

- The server-side logic can only handle one request at a time, and drops all previous requests;
- The client-side logic 'forgets' about all previous requests when a new request is made, and so only responds to the one that it understands (the last one that was sent).


I would be extremely grateful for any feedback on why this might be happening, and what I might do to get around the problem. I have considered using IFrames in my application, which all reference pages that have their own request / response handlers, but I'd rather not get into this as it will significantly alter the development model used so far.

Any help much appreciated.

Tom

推荐答案

如果您与我们共享一些代码可能会有所帮助?

请注意,如果您启用了会话状态并且请求将转到动态处理程序(aspx ashx等),那么请求将是无论如何序列化。因此,你不会看到他们只是在服务器上排队的多个请求有任何好处。

IE也只会在任何时候向同一台服务器发送2个未完成的请求,所以任何额外的AJAX请求将在客户端的HTTP堆栈中排队。因此,如果您正在使用IE调度,则对任何资源的多个请求的价值都有限。

您的IFrames解决方案会遇到同样的问题。

这也没有解释为什么您丢失请求,这就是为什么我们需要代码来获得一个想法。

It might be helpful if you shared some of your code with us?

Note if you have session state enabled and the requests are going to a dynamic handler (aspx ashx etc) then the requests will be serialised anyway.  Hence you are not going to see any benefit from having mutliple requests they'll just queue up at the server instead.

Also IE will only dispatch 2 outstanding requests to the same server at any one time so any additional AJAX requests will queue up in the HTTP stack on the client.  So if you are using IE dispatching multiple requests for any resource has limited value.

Your IFrames solution would suffer the same problems.

None of this explains why you are losing requests, which is why we need code to get an idea.


这篇关于如何使用.NET脚本回调模型发送多个同时回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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