Some web applications require large amount of initialization processing time before serving the first request. In some cases web applications may also need to load the large amount of data in first request.
In earlier versions we used write the custom code in Application_Load method in Global.asax file to handle above scenarios.
Auto Start Feature which addresses this scenario is available when ASP.NET 4.0 runs on IIS 7.5 on windows server 2008 R2.
The feature enables you to
• Starting up an application pool
• Initializing an ASP.NET application
Configuring the auto-start feature for application pool in IIS 7.5
• You need to set the following configuration in applicationHost.config file.
<applicationPools> <add name="MyApplicationPool" startMode="AlwaysRunning" /> </applicationPools>
If your application pool containing multiple applications, you can auto-start individual applications by setting the following configuration in applicationHost.config file.
<sites> <site name="MySite" id="1"> <application path="/" preloadEnabled="true" preloadProvider="PrewarmMyCache" > <!-- Additional content --> </application> </site> </sites>
When an individual application pool is recycled IIS 7.5 uses the information in applicationHost.config file to determine which applications need to be automatically started.
When you set auto-start feature for application then IIS 7.5 sends a request to ASP.NET 4.0 to start the application. In this state application temporarily does not accept HTTP requests. After the initialization process, the ASP.NET application is ready to process the requests.
Advantage Using IIS 7.5 and ASP.NET 4.0 we now have a well-defined approach for performing expensive application initialization before processing first HTML request.
Example: with this auto-start feature we can initialize an application and then signal the load balancing server that the application was initialized and ready to accept HTTP traffic.
Source: ASP.NET 4.0 White paper from http://www.asp.net