开发者

Ajax PageMethods Vs XMLHTTP

开发者 https://www.devze.com 2022-12-08 18:22 出处:网络
i have a case where when th开发者_JS百科e user closes the browser window i have to set an Application Object to null...and for this i will use the JavaScript onbeforeUnload to do the server side work.

i have a case where when th开发者_JS百科e user closes the browser window i have to set an Application Object to null...and for this i will use the JavaScript onbeforeUnload to do the server side work...

so i wanted to know which is better XMLHTTP or an ajax PageMethod...which is faster..??

i have used both and found that pagemethods require less coding...also i dont have to create another aspx page to do the server side work...

can anyone explain the difference between the two and performance wise which would be better???

thanks a lot


A server-side component should not rely on the user's actions of closing a browser (or logging out of an application). As you know, a client is never trustworthy. For example, the user could use the taskmanager to just kill the browser, or there's a power outage and the user's machine just goes off. Since you cannot rely on whether data from the client is always sent, you need to do this solely on the server-side. For this reasons, there's the notion of session handlers and most framework can hook in additional session handlers.

Those session handlers will either configure a session once it is opened (e.g. a user logs in to the application), or a session is killed (e.g. when a timeout occurs, since the user did not interact with the application for more than X minutes).

And to answer your question: Use XmlHttpRequest, as it's faster.

0

精彩评论

暂无评论...
验证码 换一张
取 消