views:

1121

answers:

2

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 :-|

A: 

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.

Aliixx
I don't see how your example is related to Ajax. Besides i don't want some page resetting the timeout period all the time; reset should only happen if there is genuine user interaction - either via postback or Ajax partial page refresh.
joedotnot
hidden iframes can provide the most effective ways to achieve such keep alive functions where a server refresh is needed.you can use the RegisterStartupScript method of the ScriptManager to communicate with the hidden iframe through any basic javascript function. Then you you can manage your sessions anyway that you would like through javascript / server side callbacks.Alternatively, you would be best served using jQuery or such and use the $.post(..) methods to achieve ajax communication / functionality.
Aliixx
A: 

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.

awe
repeating comment above: So are you saying i don't need to do anything to keep resetting the timeout period? Since the postback is already happening, it is already being reset?
joedotnot
Yes. It would be a horrific design flaw by Microsoft if the session wouldn't be kept alive in this case... Have you encountered some actual problems with this, or did you just think it would be a problem?
awe
I have a bug that needs investigating, so wanted to get ahead by understanding standard behavior; your response tells me using the UpdatePanel and Ajax is not the issue. I will provide an update in the next few days. Thank you.
joedotnot
Update: my issue was totally different, a 'Refresh' Http-Header was sent to the browser on every form load, to redirect to a login page after 20 mins; this Http-Header would get refreshed with another 20 mins, upon a full postback; Using Ajax, the header was not getting refreshed.
joedotnot