Learn More





DNN Community Blog

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.

Creating a Local Keep Alive Service on your Web Server

Most of us have experienced that lesser visited DNN (or other ASP.Net) web sites need some time to start when browsing to the first page. The reason for this is the shut-down of the ASP.Net worker process that happens after no request to the Application Pool has been done for a given number of time - the default is 20 minutes. Beyond that, the worker process is shut down every 29 hours (1740 minutes) by default even when it is not idle.

What happens when a request comes in?

These are the first steps that happen against a client request:

  1. IIS checks whether a worker process is active or not.
  2. If not:
    1. IIS it creates the worker process by starting w3wp.exe.
    2. The worker process hosts aspnet_isapi.dll - this is the handler mapped to "aspx" files. IIS checks for the script map and routes the request to the handler.
    3. The request is passed to the .Net runtime (which is hosted in the worker process as well).
    4. The application domain is created by a class called ApplicationDomain. This provides isolation between different applications, e.g. for global variables, and allows to unload applications separately.
    5. Inside the application domain, the hosting environment is created as an instance of the HostingEnvironment class. It provides information about the application such as a unique application ID, the physical path on disk where it is stored, the name of the site etc.
    6. ASP.Net creates core objects like HttpContext, HttpRequest, HttpResponse etc.
    7. The application is started as an instance of the HttpApplication class - or, if there is a global.asax file, it creates an instance of it's own class (that derives from HttpApplication).
    8. If required, ASP.Net compiles the top-level items in the application (including code in the App_Code folder).

Keep Alive Services

It is (or should be) quite clear that this takes some time, and therefore it is quite clear why we have to wait sometimes. The good news is that you can do something against it. One solution could be to increase the value(s) for the shut-down(s) in IIS Manager by configuring the application pool. This will help only if you can say that you have one visitor e.g. once an hour and set the time-out to e.g. 90 minutes - but are you really sure about this?
The other way is to use a keep-alive service, such as the great and free DNN Monitor that makes a request to your web site every five minutes - and also records response times and provides some statistics for you.
But what if this is a website in your intranet that is not accessible for DNN Monitor?

There are two things to know:

  • DNN provides a script named KeepAlive.aspx (which resides in the root of the DNN installation). This script is doing nearly nothing, it contains a call to an ASP.Net method that returns the server's current date and time, and uses the HTML-Meta-Tag to reload itself every 5 minutes.
  • Windows contains a very powerful command line shell named Windows Power Shell.

Knowing the first one allows you to install a keep-alive service. Just start a browser on any PC in your network and call the KeepAlive.aspx page (e.g. by typing in your browser's address bar. Don't close the browser, don't log off or shut down the computer and you're done.

There is a more elegant way. You can write a Windows Power Shell script using your preferred text editor. The script requests the web site, and then you can call the script on a regular basis using a scheduled task. The script is not really complicated, it just instantiates a web client object and requests the page:

$WebClient = New-Object Net.WebClient

Save the script somewhere on your web server, e.g. C:\PowerShellScripts\KeepAlive.ps1. Open Power Shell, navigate to the folder where you stored it and execute the script:

PS H:\> C:
PS C:\> CD \PowerShellScripts
PS C:\PowerShellScripts> .\KeepAlive.ps1
<html> (... Lot of stuff ...) </html>

Got an error? The reason is most propably the execution policy that requires signed scripts. You can change this to Remote Signed by entering

Set-ExecutionPolicy RemoteSigned

You can avoid the output by assigning the last call to a variable, so change the second line of the code to

$Source = $WebClient.DownloadString("")

The last step is to create a scheduled task on your web server that starts powershell.exe under the SYSTEM account every 5 or 10 minutes with the name of the script as parameter. You can do this using the graphical interface for Scheduled Tasks in Windows or using the SCHTASKS command (in a command window or Power Shell):

SCHTASKS /CREATE /RU SYSTEM /RL HIGHEST /TN "Keep Web Site Alive" /SC minute /MO 10 /TR "powershell.exe C:\PowerShellScripts\KeepAlive.ps1"


Happy DNNing!


Richard Howells
Hi Michael. If you are on IIS recent. I think it's IIS 8 and later you can do this with a setting.

Go to site settings advanced and set Preload to True.
Richard Howells Thursday, July 17, 2014 8:58 AM (link)
Michael Tobisch
Hi Richard, thanks for this useful information. In my eyes, the app pool recycling makes sense (as it releases a lot of unused resources) - but I'll check if this still happens with this setting.

Best wishes
Michael Tobisch Thursday, July 17, 2014 10:14 AM (link)
Richard Howells
Hi Michael. I believe the recycling still takes place. AIUI after the fresh AppPool is ready to go the system sends a priming request through for all sites using that pool which have Preload=True. Then the fresh AppPool is swapped for the old one.
Richard Howells Thursday, July 17, 2014 11:13 AM (link)

Comment Form

Only registered users may post comments.


2sic Daniel Mettler (124)
Aderson Oliveira (15)
Alec Whittington (11)
Alex Shirley (10)
Andrew Nurse (30)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (21)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (203)
Chris Paterra (55)
Clinton Patterson (28)
Cuong Dang (21)
Daniel Bartholomew (2)
Dave Buckner (2)
David Poindexter (3)
David Rodriguez (2)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (74)
Geoff Barlow (6)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (269)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matthias Schlomann (15)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Mike Horton (19)
Mitchel Sellers (28)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Peter Donker (52)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott S (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Timo Breumelhof (24)
Tony Henrich (3)
Torsten Weggen (2)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (37)
Will Strohl (163)
William Severance (5)
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?