28

I think my Webapplication gets shut down after a while.

It returns a new session if I haven't used the application in maybe 5 minutes. The session timeout is set to 720 minutes so that can't be the issue.

Is it maybe a setting in the Application Pool or something like that? I figure it is some sort of resource management. I use IIS 7.0

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
The real napster
  • 2,274
  • 7
  • 23
  • 33
  • For security and data integrity reasons (depending on website design), I think all interactive websites should have a timeout – Fandango68 Jun 05 '22 at 23:09

9 Answers9

58

IIS has a feature in properties where you can stop recycle your IIS on intervals

  1. Go to your "IIS Manager"
  2. Select "Application Pool" the instance you want to manage.
  3. Select "Advanced settings" action
  4. Under "Recycling" and set "Regular Time Interval" to 0, which means the application pool does not recycle.
Mohamed Mansour
  • 39,445
  • 10
  • 116
  • 90
  • 1
    This is the *right* answer. The OP is long gone though. – Michael Brown Jul 26 '16 at 15:33
  • 6
    Mine was set to 1740 minutes (29 hours) which [is the default and has been since application pools were added to IIS](https://weblogs.asp.net/owscott/why-is-the-iis-default-app-pool-recycle-set-to-1740-minutes) so I don't think this can be it - the question said it was 5 minutes. – MrLore Nov 18 '16 at 09:33
  • 2
    if there is a memory leak, this might crash the system – Otabek Kholikov Mar 13 '19 at 17:40
38
  1. Open "IIS Manager"
  2. Select "Application Pool" the instance you want to manage
  3. Select "Advanced settings"
  4. Under "(General)" and set "Start Mode" to "AlwaysRunning", which means the application pool keep the ASP.NET application run always

PS. If you want the ASP.NET application be loaded automatically, you can follow this:

  1. Open "IIS Manager"
  2. Select the application you want to manage
  3. Select "Advanced settings"
  4. Under "(General)" and set "Preload Enabled" to "true", which means the applicaton will be loaded automatically after its deployment.

For more information, please visit this:Use IIS Application Initialization for keeping ASP.NET Apps alive

guogangj
  • 2,275
  • 3
  • 27
  • 44
  • This doesn't work as you would expect ... we have the above problem and this is where I started. – War Jul 11 '17 at 08:06
  • Keep in mind - "Preload Enabled" to "true" will work only with anonymous authentication turned on. – Raf Oct 27 '21 at 06:28
12

We had the same issue with a web service that had to stay online in such a way that we couldn't afford the latency involved in starting it up if it went stale.

We wrote a very simple Windows Service that woke up every 3 minutes and requested a page as @Wayne suggested. Worked like a charm.

Andrew
  • 11,894
  • 12
  • 69
  • 85
  • Totally forgot about windows services, that would be pefect for this... Let me know if you have it and want to send it over as I haven't created a windows service for years :) – The real napster Apr 23 '09 at 12:31
  • I must admit, for our sites I actually use a minimised winform with embedded .NET browser control that read's a list of URL's from a txt file and requests each one into the browser – Wayne Apr 23 '09 at 12:50
  • Sorry, napster. No can do. As much as I'd like to, the powers that be would NOT be impressed. There are plenty of samples around the 'net, so it won't be hard to put one together. – Andrew Apr 23 '09 at 12:59
  • If anyone reads this and have the same needs you can find information on how to make HTTP Requests from C# here: http://www.codeproject.com/KB/cs/Browsing_the_WEB_with_C_.aspx – The real napster Apr 23 '09 at 15:52
3

The simplest way is to use a script to open a connection to the website and request your page. See Joel Oleson's Blog for more information.

You can use windows scheduler to run every x minutes.

This maybe Sharepoint specific but you can adapt to your requirements.

Update: Try this version: WarmUpServer.zip

Wayne
  • 3,415
  • 1
  • 22
  • 21
  • the files no longer exists in that blogpost... otherwise seems to be what I was looking fore, anyone have a script that can do this for me? – The real napster Apr 23 '09 at 11:59
1

After some research on this subject, I manage to find a good reference (Scott Forsyth's Blog) and it worked for me like a charm (IIS 10, but I belive it should work starting on IIS 7). Basically, you need to set application pool Idle Time-out to 0, otherwise, when you have 20 minutes without any traffic then the app pool will terminate.

On IIS, go to Application Pools --> right click on the poll you want to edit --> Advanced Settings. Under Proccess Model, change the Iddle Time-out property to 0.

application pool advanced settings

tgoliveira11
  • 11
  • 1
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '22 at 13:56
  • To piggy back on this. You can set the idle timeout via the appcmd.exe tool. This is useful if you need to set it through an automated deployment tool. `%systemroot%\system32\inetsrv\appcmd.exe set apppool "AppPoolName" /processModel.idleTimeout:0.00:00:00` – cminus Nov 15 '22 at 13:15
0

After failed at configuring IIS pool. I come out with this simple windows service. github code

It can save some minutes of you.

Chinh Phan
  • 1,459
  • 19
  • 22
0

"Preload Enabled" to "true" will work only with anonymous authentication turned on.

Raf
  • 203
  • 2
  • 11
0

If you are using Windows Server 2008 and above, it's easy to use the built in Task Scheduler to configure a automatic request the page's URL with the default browser (in the windows server).

Guide: https://windowsloop.com/open-webpage-on-schedule-task-scheduler/

I've been using this method to keep my site running as it has some scheduled background tasks in IIS.

Harvey Darvey
  • 706
  • 8
  • 16
0

Application pools do recycle, and they do restart after achieving some limits in terms of execution time or number of requests etc, that can be set on IIS.

IIS 7 actually runs in pipeline mode so its something new which we dont know yet for sure, but all you can do to make your app alive is to set a trigger from some other machine which will connect your server in every 5 or 10 or 60 minutes and try to fetch one html page.

There can be various server monitors for http as well.

Akash Kava
  • 39,066
  • 20
  • 121
  • 167
  • 1
    well I most likely wont experience this problem once we go live because there will be a lot more usage but still it is annoying as hell... It seems so stupid to set up a ping from another server though, I refuse to believe that is the best solution :) – The real napster Apr 23 '09 at 12:07
  • @napster: You're unlikely to find a better solution unless you switch to a different web server. – Roy Tinker Oct 03 '11 at 19:25
  • 2
    "but all you can do to make your app alive is to set a trigger from some other machine", why does it have to be some other machine? can't it run on the server machine? – Peter May 30 '13 at 10:39