ASP.NET AJAX and keeping the Session alive - What is the standard way to do it?

我的梦境 提交于 2019-11-30 19:32:45

问题


Long time ASP.NET Webforms developer, new to Ajax development (mostly via the UpdatePanel control !).

Since no postbacks are happening the server does not reset the user’s session timeout counter, even though a user is interacting with a page and refreshing parts of it.

I would like to know what is the simplest and standard way of keeping the ASP.NET session alive, when one is developing Ajax with the UpdatePanel;

Please provide code and/or links in your answer; The stuff i searched talks about frameworks, JQuery, JSON, and whatever is the flavour of the month acronym, i don't need anything fancy, just the plain standard way of doing it, i don't care if it's not optimized, etc :-|


回答1:


As GenericTypeTea commented, there are server side postbacks when using .NET AJAX with UpdatePanel. The only difference is that the entire page is not loaded. All the server side code is triggered as normal, but the information is sent between the server and the page in a different way using the AJAX technology.

You can even call server side methods from client side javascript using a mechanism that .NET calls PageMethods. This is a more "manual" way of using AJAX in .NET than the traditional UpdatePanel technique.




回答2:


I would say using a hidden iframe for communication would be the easiest wa ywith least hassle. http://weblogs.asp.net/stephensonger/archive/2009/04/22/keeping-asp-net-sessions-alive.aspx has a good example that you can expand on.



来源:https://stackoverflow.com/questions/1587449/asp-net-ajax-and-keeping-the-session-alive-what-is-the-standard-way-to-do-it

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