May 23 2006

Session_End and HttpRuntime

Category: ASP.NET 1.x | ASP.NET 2.0 - GeneralBil@l @ 06:53

I had a need few days ago to delete some files in the Session_End. As you know, Session_End will be fired, even if the client's session ends, because the Session is based on the Server and therefore, after the Session times-out the Session_End on the server will be executed.

However, I needed to use some properties from the HttpContext and it happened that thre is not always an Active Context when the Session_End fires, especially when the browser is closed from the client side before the session expires.

So to overcome this, you can use HttpRuntime, and I mainly used HttpRuntime.AppDomainAppPath to get the physical path of my application to locate the files I need to delete.

Hope this trick helps you out!

Regards

Tags: ,

Comments are closed