Does Session timeout reset on every request regardless of whether we check sessions variables? Or we should use atleast one session variables?
Does Ajax request cause resetting session timeout? like Update Panel
,jQuery ajax
,...
thanks
Edit 1)
Does HTTP Get
cause resetting session timeout??
yes, it does. it doesn't matter whether you actually use the
Session
or not.However, if you're using only ajax calls, you might run into some problems.
(although I haven't encountered it myself, here's an explanation)
This will depend on a lot of factors so I suggest you run a test like below. It really takes less than 5 minutes to find out if your exact situation works in your environment. Here is my code that I used to test this, I use Telerik controls to test the idea but I added a .get to get the exact answer you wanted. aspx page has
the .cs page has
---you can arrange the above to fit your situation. But the idea is simple. You load the page. Click on the "Renew" button and this will set your session. Wait 61 seconds and the page will refresh and the session variable is gone. Try it again but this time click on one of the other two buttons after a few seconds and when the page refreshes you will see that the session variable has stayed intact from the ajax calls. The ajax call in this situation refreshes the session variable.
Session
will not expire if you keep on calling server side code. Thesession
time out will be resetting on each request to server. On subsequent requests to the same web site, the browser supplies theASP.NET_SessionId Cookie
which the server side module uses to access session value(like user information).Session
will expire in case user waited too long between requests.Session
will not expire if you keep on callingserver side
code. Thesession
time out will be be resetting on each request to serverDoes Session timeout reset on every request regardless of whether we check sessions variables? Or we should use atleast one session variables?
Until a session variable is established, a new session id is generated for every post back.
Does Ajax request cause resetting session timeout? like Update Panel ,jQuery ajax ,...
Session ID which is saved in the cookie by default, is sent for every AJAX as well as non AJAX request. Hence the server is aware that the session user is active. Don't take my word for it. Use fiddler or the F12 tool within ie. You can see the cookies being sent out with every AJAX GET/POST request.