1
votes

I have made an asp.net application. This application has session variables which shows that a user is logged in or logged out. If there any way to capture the expiration of session without going to single pages and once this is logged out user can be redirected to login( Re-login) page?

Can my asp.net classes inherit some base class which can have some abstract method to check if session is existing or not.

Please suggest me some architecture to do this.

Thanks in advance.

2

2 Answers

2
votes

This application has session variables which shows that a user is logged in or logged out.

This can be achieved by checking the HttpContext.Current.Request.IsAuthenticated property.

If there any way to capture the expiration of session without going to single pages and once > this is logged out user can be redirected to login( Re-login) page?

Configure the following elements in your applications web.config to restrict\allow access to resources\pages\directories on your site:

<authorization> 
   <allow .../>
   <deny .../>
</authorization>

http://msdn.microsoft.com/en-us/library/8d82143t

And, configure the FormsAuthentication defaulturl and loginurl attributes to redirect users away from restricted resources.

1
votes

You can use global.asax's session end event:

void  Session_End(Object sender, EventArgs E) {
// your code....
}

When the session expire this event called.