Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hashtable sessions = (Hashtable)System.Web.HttpContext.Current.Application["WEO"];


C#
if (System.Web.HttpContext.Current.Application["Login"] != null )
                {
                    sessions.Remove(System.Web.HttpContext.Current.Application["Login"].ToString());
                }



I need to execute the above lines before session expiration...

Is there any event before session expired??

How can i call the above code.. in the case of session expiration in my application....


Thanks,
honey
Posted
Updated 28-Oct-14 4:45am
v2
Comments
Rocker-Star 28-Oct-14 11:20am    
I would be using Session object instead, there is no point in adding Application object and removing it. at what point do you add the Login key on to your application object?
honey4bee 28-Oct-14 23:43pm    
For avoiding multiple user logins I used to store that application object to hash table, i succeed in all cases except session expire..

Please see this CodeProject article: Alert Session Time out in ASP.NET[^].

—SA
 
Share this answer
 
Comments
Maciej Los 28-Oct-14 13:00pm    
+5!
Sergey Alexandrovich Kryukov 28-Oct-14 13:04pm    
Thank you, Maciej.
—SA
Have a look here: Session-State Events[^]
MSDN wrote:
You can handle the Session_OnEnd event by adding a subroutine named Session_OnEnd to the Global.asax file. The Session_OnEnd subroutine is run when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session.


Sample code: alert user session expire (AspNetAlertSessionExpire)[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Oct-14 13:04pm    
5ed.
—SA
Maciej Los 28-Oct-14 13:08pm    
Thank you, Sergey ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900