Using Session variables in Session_End

I encountered a problem where i needed to delete a folder from my application root folder at Session_End event. The folder name was assigned by the session id. I tried to access the session using HttpContext.Current object but in this time, the object is null because there is no web request however i looked at the HttpApplication class in which the Global class is derived, i found out a property called Session. Using the Session property, you can access all the session properties, methods.

  protected void Session_End(Object sender, EventArgs e)
  {
   string sessionID = Session.SessionID;
   Session.Abandon(); 
  }

Best Regards,

HC

Comments

# re: Using Session variables in Session_End

Wednesday, August 08, 2007 10:45 AM by Venkatesh

Hi..

I am trying to delete a folder. The folder name was assigned by the session id.

When I try to delete the folder, the IIS gets re-started. How to avoid this?

# re: Using Session variables in Session_End

Tuesday, October 02, 2007 11:17 AM by Pablo

It could have something to do with the fact that ASP.NET is monitoring the file system for modifications, so that it can restart when web.config is changed, for example.

Don't place those dynamic folders within your application's folder.

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.