Click to See Complete Forum and Search --> : Server operation is not available in this context.


SatyaV
February 28th, 2005, 04:29 PM
My app has to cleanup some directories when a session ends. For this I need to find the physical location of a dir under the webapp's root location. Normally, on a page you can use Server.MapPath(pathname) to get this info.

However, this does not work in the Global.asax Session_End method. The code compiles, but a runtime error occurs - "Server operation is not available in this context." Any ideas on how to fix this?

Thanks.

SatyaV
March 3rd, 2005, 11:17 AM
Possible workaround is to create a class variable in the Global class, and initialize it with Server.MapPath(null) in the Application_Start function. This value can then be used in Session_End method. Can anyone validate this method ??

This is working fine for my application, but documentation says that multiple HttpApplication modules can be created during an app's lifetime and all of them may not call Application_Start ?