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

Published 02 July 2007 02:57 AM by haissam

Comments

# Venkatesh said on 08 August, 2007 10:45 AM

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?

# Pablo said on 02 October, 2007 11:17 AM

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.

This site

Search

Go

This Blog

Syndication

Sponsors

  • MaximumASP
  • Packet Sniffer