ASP.NET AJAX using UpdatePanels

只谈情不闲聊 提交于 2019-12-10 23:35:03

问题


Conceptually, my understanding of AJAX is requests sent to the server asynchronously aka in parallel. When I use multiple UpdatePanels on a page and trigger multiple async postbacks (say by using a button), I notice that the second request is not started till the first one is complete.

However when I use JQuery ajax and use PageMethods/WebMethods, my requests are processed in parallel.

Why is there a discrepency in the way ASP.NET AJAX behaves?

Also, when I click the button in the UpdatePanel repeatedly, it aborts previous requests. I was expecting them to be queued.

any help?


回答1:


Because it must behave that way.

An UpdatePanel's asynchronous postback is still just that: a postback. If multiple postbacks were allowed to occur in parallel, their new ViewStates would often be out of sync with each other. Then, the very next postback would throw a ViewState validation error and/or one of the postbacks' modifications to the Page's state would be lost after the third postback completed.

On the other hand, page method and web service calls are not encumbered by the WebForms ViewState or page life cycle. So, as many of those may occur in parallel as the browser's simultaneous request limit allows (usually 4-8, but only 2 in some browsers like IE6).




回答2:


This blog post seems like it addresses your problem and provides a solution. He uses some javascript to queue multiple requests and sends them to the server in a batch (I think).



来源:https://stackoverflow.com/questions/4417442/asp-net-ajax-using-updatepanels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!