Friday, January 8, 2010
Handle Session Timeout
The problem
The CDS application I am developing in RBC has an unexpected behaviour upon session timeout. When click to navigate to the next page, it exceptioned rather than navigating to the login page as other buttons do.
The reason is that the base page handle session timeout later than logic in Page_Index_Changed event handler. Session timeout cause the session-stored record set lost, the databind method won't work because requested page is not exist - the page index is greater than total pages count.
The solution to this is to verify if current session is timeout. The following code solves the problem:
if (Context.Session != null && Session.IsNewSession)
{
return;
}
Note, Context.Session != null checks if there is a session object available, usually it is available, because any time a request comes, the application will either find one or create one if no session id comes along or it can not find the session object.
Application determine if it is a new session by checking if the request comes along with a session id, if yes, then it is not a new session. Otherwise, the application will create a new session and put into the http header to be part of the response.
Subscribe to:
Post Comments (Atom)
1 comment:
when client support cookies, you won't see session id on url, because it is transfered through cookie. In any case the session id has to be tranfered along every request. good stuff.
Post a Comment