I have an application where each user's interaction with the site takes many pages and lasts up to 10 minutes. It runs 24/7 in its own apppool.
As the user progresses through the pages, I store the data they provide in the session state.
I have disabled automatic recycling to avoid the session state getting destroyed mid-interaction, and I've tried to schedule a recycle at a specific time (4am on Tuesdays) with a timer in the Application.Start event. I've tried many approaches from different
forums - currently HttpRuntime.UnloadAppDomain(). The Application.OnEnd and Application.Start events fire and the code runs, but the "old" version of the app seems to continue running. Eventually the site goes non-responsive.
How can I programatically cause the app to stop and then restart as if the application pool had recycled?
Member
4 Points
58 Posts
How to stop an application
Jan 12, 2016 09:12 AM|iLens|LINK
I have an application where each user's interaction with the site takes many pages and lasts up to 10 minutes. It runs 24/7 in its own apppool.
As the user progresses through the pages, I store the data they provide in the session state.
I have disabled automatic recycling to avoid the session state getting destroyed mid-interaction, and I've tried to schedule a recycle at a specific time (4am on Tuesdays) with a timer in the Application.Start event. I've tried many approaches from different forums - currently HttpRuntime.UnloadAppDomain(). The Application.OnEnd and Application.Start events fire and the code runs, but the "old" version of the app seems to continue running. Eventually the site goes non-responsive.
How can I programatically cause the app to stop and then restart as if the application pool had recycled?
Participant
1779 Points
852 Posts
Re: How to stop an application
Jan 13, 2016 03:10 AM|TechView|LINK
If you want to set duration in the app pool, this would be recommended and hopefully helpful too:
https://www.iis.net/configreference/system.applicationhost/applicationpools/add/recycling?_e_pi_=7%2CPAGE_ID10%2C6936134746
And to do it programmatically, follow the below links:
http://www.codeproject.com/Articles/26430/Recycling-IIS-application-pools-programmatical
http://www.kunal-chowdhury.com/2013/08/how-to-manage-iis-application-pool.html
http://weblog.west-wind.com/posts/2007/Jan/17/Programmatically-listing-getting-and-setting-Application-Pools
TechView
All-Star
17652 Points
3510 Posts
Re: How to stop an application
Jan 13, 2016 08:46 AM|Chris Zhao|LINK
Hi,iLens
The following code examples add an application pool named Contoso to IIS 7 server, then set the application pool to daily recycle at 3:00 A.M.
More information, please see here.
Best Regards,
Chris Zhao