Click here to Skip to main content
15,881,204 members
Articles / Web Development / ASP.NET

IIS 8.0 Asp.net warm up Auto Start & Application Initialization

Rate me:
Please Sign up or sign in to vote.
4.94/5 (9 votes)
10 Jul 2014CPOL3 min read 89.8K   590   14   6
Steps to setup IIS Asp.net Warmup module. Describe usage of Preload- System.Web.Hosting.IProcessHostPreloadClient
  1. Introduction
  2. Prerequisites
  3. Create Your Warmup Script Assembly
  4. Application Pool: Demo Website
  5. IIS Web Server: Configuration Editor
  6. system.applicationHost/applicationPools
  7. system.applicationHost/ServiceAutoStartProviders
  8. system.applicationHost/Sites
  9. Application Initialization
  10. Final Step: Now Run this animal
  11. Reference

Introduction

I've been working on IIS asp.net warm up thing for quite sometime and I tried all possible ways to get my warm up script working but it failed to initialized and auto start. After spending some time understanding some of the flow and internal mechanism of request flow, we able to crack the solution. This article will somewhat help you find the resolution to most common problem that we may have to tackle when enabling warmp script in IIS. I started looking few articles around IIS7.5 and auto start app pool but hardly find the resource online to give me crisp and clear steps to enable this.The overall intent of this article is to provide the end to end steps and some known issues that one would run into.There is sample demo code one can download to setup warmup thing for your website. I haven't gone to extend to explain why we need IIS asp.net warmup however I covered the most likely configuration settings that would go into running the warm up script.

Prerequisites

The Application Initialization feature requires IIS 8.0 to be installed. In addition, the Application Initialization feature within the IIS "Application Development" sub-feature needs to be installed. The following screen shot from the Windows Server 2012 Server Manager UI shows the Application Initialization feature. IIS 8.0 Application Initialization Setup Key Note: Restart server to effect above changes. This initialization plays important role when we have to execute any startup page automatically without users access any web pages. Sometimes warmp up fails to start because there is some setting that needs to be enabled under [code]<system.webserver> applicationInitialization[/code]

AddRoleFeature

ApplicationInitialization

Create Your Warmup Script Assembly

Warmup Sln

This warmp script will be executed at the start up of IIS app pool recylce or at time of website initialization. There can be various scenario we can embed in this start up script.Like we can have warm up script for Caching web pages or getting ready canned reports or any heavy task which takes longer time to load.For demo purpose I kept the code setup simple, to just create folder + file. Remember never have such filesystem read write operation withing website virtual directory or website directory it results in application app pool recycle everytime the filewrite operation takes place.

PreWarmupCache

Application Pool: Demo Website

Enable Start Mode="Always running" from OnDemand Mode

PreWarmupCache

IIS Web Server: Configuration Editor

Go to Main Application IIS Root. select Configuration Editor. Changing applicationhost.config is much safer through configuration editor than doing it manually.

ApplicationHostConfig

system.applicationHost/applicationPools

Click on collection to proceed. Ensure highlighted property are set as given below in the screenshot.

system.applicationhost

Check AutoStart mode=true

ApplicationPool-AutoStart

Check StartMode mode=AlwaysRunning

ApplicationPool AlwaysRunning

system.applicationHost/ServiceAutoStartProviders

Click on collection to proceed. Ensure highlighted property are set as given below in the screenshot.

ApplicationHost ServiceAutoStart Providers

Add Assembly and class reference warmup script pacakage in ApplicationHost.config ServiceAutoStartProviders tag. We've indicated this provider with name say PreWarmUpMyCache- Mind it- MY. Next we need to provide this reference to site tag in configuration as next step. Remember type=Assembly Full Name.ClassName,Assembly Full Name

ApplicationHost ServiceAutoStart Providers

system.applicationHost/Sites

Click on collection to proceed. Ensure highlighted property are set as given below in the screenshot.

Set ServerAutoStart=true

ApplicationHost ServiceAutoStart Providers

Set preLoadEnabled=true

Set serviceAutoStartEnabled=true

Set serviceAutoStartProvider=PreWarmUpMyCache

ApplicationHost ServiceAutoStart Providers

ApplicationHostServiceAutoStartProvider2

Application Initialization

Troubleshooting 1:Ensure your assembly is compiled and exists in bin folder of website.

Troubleshooting 2:Worst case even if warmup script not called ,try including default web page access auto initialize.Refer screenshot.

 ApplicationIntializationMythe

Final Step: Now Run this animal

Sample Code is attached for demo purpose. Download it and apply above setting to test run the demo.

References

IIS Auto Start Warm up By Scott Guthrie

IIS Tech net

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Australia Australia
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!
www.santoshpoojari.blogspot.com

Comments and Discussions

 
SuggestionYou've messed up two different approaches Pin
odinserj9-Jun-16 0:29
odinserj9-Jun-16 0:29 
GeneralRe: You've messed up two different approaches Pin
Member 1020127513-Feb-17 2:31
professionalMember 1020127513-Feb-17 2:31 
QuestionWhere should I put the Demo.PreWarmUpMyCache.dll? Pin
ikcelam27-Oct-15 1:01
ikcelam27-Oct-15 1:01 
QuestionIs it possible to use configuration file Pin
Member 1188405112-Oct-15 22:49
Member 1188405112-Oct-15 22:49 
QuestionApplication Initialization Warmup period Pin
SethuramR7-Oct-14 23:46
SethuramR7-Oct-14 23:46 
GeneralMy vote of 5 Pin
Ashish Chavan10-Jul-14 2:49
Ashish Chavan10-Jul-14 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.