I have tried to find a simple method to keep my website alive, thus never have to see the sitefinity startup screen as soon as the number of requests to the website goes down.
The code I found has been tested and works quite well in my local development environment.
If we place this bit of code in the Global.asax and call it when Application_Start() is raised, we can basically start a job that keeps our website alive. You could just as easily use a Thread to host the refresh method but for this example we simply used an Action delegate.
Once our application starts the refresh job is also started and is saved to the cache. In this example we’re using 60 seconds, but you can change this to be as often as you like.
This snippet uses a WebClient to actually make an HTTP call to our website, thus keeping the site alive! We could do any number of things from this code like updating local data or get information from external resource. This can be used to keep our site alive and our content refreshed, even if we’re using a Hosted Environment!
It is worth nothing that might not actually need to do an HTTP call back to your website. It is possible that using any method will keep your website from being killed off (but I haven’t tested it yet so let me know what happens if you try it).
I have not noticed any interference with Sitefinity so far, and would be surprised if problems occur.
public class Global : HttpApplication
private static readonly log4net.ILog GlobalLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected void Application_Start(object sender, EventArgs e)
// Configure Log4Net
// Keep our website warm
/// Keep our website refreshed and warm for fast response even during low load.
/// NOTE: This code was copied from an article on codeproject.
private static void _SetupRefreshJob()
// Remove a previous job from the cache
Action remove = HttpContext.Current.Cache["Refresh"] as Action;
if (remove is Action)
// Get the worker
Action work = () =>
// Set time interval to 60 seconds.
WebClient refresh = new WebClient();
catch (Exception ex)
// Add this job to the cache.
(s, o, r) => _SetupRefreshJob();