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
Application_End() event is fired without any call in global.ascx
2.7k Views Asked by Rupendra At
4
There are 4 best solutions below
2

First place to look into is the Event Viewer. There you can find any unhandled exception thrown in the worker process.
0

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.
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.