Click here to Skip to main content
Click here to Skip to main content

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

, 10 Jul 2014
Rate this:
Please Sign up or sign in to vote.
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] 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)

About the Author

santosh poojari
Technical Lead
India India
Whatsup-->Exploring--> MVC/HTML5/Javascript & Virtualization.......!
www.santoshpoojari.blogspot.com

Comments and Discussions

 
GeneralMy vote of 5 PinmemberAshish Chavan10-Jul-14 2:49 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 10 Jul 2014
Article Copyright 2014 by santosh poojari
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid