the Application_End() event in my application is getting fired without any call to the event by my code after i fire a button for update or delete process. this causes all the Sessions destroyed and redirects the user to Login page every time he update/delete some thing. I think this is happening due to some Exception which is terminating and restarting Application without any warning or error. Please suggest. Prior thanks
4 Answers
Running in debug mode? The AppDomain gets recycled every 15 dynamic recompilations. It recycles when files change too, e.g. web.config
. It even recycles when non-application files and folders change within the app site. So test to see if this still happens in Release mode.
Incidentally you can change the number of dynamic recompiles that force an AppDomain reset: In the web.config
set it here:
<compilation numRecompilesBeforeAppRestart="15" />
Tip: Don't use InProc sessions while debugging - use StateServer or SQL State (my preference) instead.
See this blog post for more info.

- 9,217
- 3
- 47
- 57
First place to look into is the Event Viewer. There you can find any unhandled exception thrown in the worker process.

- 17,167
- 7
- 49
- 85
-
hi onof, i got this from event viewr, - - EventData /DevelopmentWebsite E:\Ashu\Source\WebSites\DevelopmentWebsite\ OPTIMUS2-PC 4488 WebDev.WebServer.EXE optimus2-PC\optimus HttpException Session state is not available in this context. at System.Web.HttpApplication.get_Session() at ASP.global_asax.Application_End(Object sender, EventArgs e) in e:\Ashu\Source\WebSites\DevelopmentWebsite\Global.asax:line 60 – Rupendra Jul 20 '11 at 10:52
-
Maybe your app need to run in classic mode but is running in integrated mode (see the application pool) but it's hard to help without details – onof Jul 27 '11 at 15:47
Your site may be recycling for some reason. You will have to check what the code does. I suggest checking that the site structure is not being altered in you code (create/remove directory) --- this leads to the app domain recycling.

- 12,983
- 2
- 27
- 48
Session state is not available in Application_End. It's that simple. Application_End is an event that fires after everything else is long gone. The event log entry describes this quite well.

- 1,498
- 8
- 11