简体   繁体   中英

Application_End() event is fired without any call in global.ascx

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

Running in debug mode? The AppDomain gets recycled every 15 dynamic recompilations. It recycles when files change too, eg 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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM