Question

is there a way to create a new session if it has timed out ? in mobile appication developing using asp.net?

getting this error:

the page requires session state that is no longer available. either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. try increasing the history size or session expiry limit

this is what i have in my web.config:

  <sessionState cookieless="UseCookies" cookieName="Mobile_Session" regenerateExpiredSessionId="true">
    </sessionState>
Was it helpful?

Solution

Session handling is done on the server so if the client sends a request after their current session has timed out the the ASP.Net application will automatically create a new session.

As far as I know once the session has timed out it is not possible to restart it or recover information from it. If you want to prevent a session from ending then you could send a small AJAX request periodically to prevent it (e.g. if you session ends after 20 minutes then send a request every 15 minutes). This request would force the session to stay active.

OTHER TIPS

Once the session has expired, there's no way to get it back. You have several options.

  • Increase the session timeout in your web.config settings (make it last longer)
  • Periodically cause a postback to refresh the session timeout (this is usually done in a hidden iframe so the user doesn't know or some kind of popup to give the user the option)
  • Redirect the user to a login page or home page and explain to them that their session expired. Its also helpful to save the originally requested url in the newly created session so they have the option to return to the page they were on.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top