IIS 7.5 which is ships with Windows Server 2008 R2 and Windows 7 provides a new feature for Web Applications. This feature allows one to install a Web Application which is not initialized after receiving of the first request started. Instead such application is started immediately after it is configured to run in this mode which is called “Always Running”. Always Running is more an attribute of the application pool than of application. The same feature is supported by ASP.NET 4.0. In ASP.NET 4.0 context it is simply called “Auto-Start”.
To setup the pool set the attribute startMode to AlwaysRunning of the IIS config file C:\Windows\System32\inetsrv\config\applicationHost.config:
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>
Immediately after saving of the changed config-file the new process W3WP.EXE will be started.
If you want to specify which application will be auto=startable see following example:
<sites>
<site name="SomeSite" id="1">
<application path="/" serviceAutoStartEnabled="true" />
</site>
</sites>
Additionally you can even implement some kind of reloading functionality called Auto Start Provider. To do that implement the interface IProcessHostPreloadClient .
While the application is starting one specific method of that provider will be called to do whatever on start-up. While the application is starting app, no request will be executed by IIS.
public class MyStartUpCode : System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
. . .
}
}
To register the custom Auto Start Provider code:
<serviceAutoStartProviders>
<add name="MyAutoStartProvider" type="MyStartUpCode, TheNameOfMyAssembly" />
</serviceAutoStartProviders>
To activate it do following:
<sites>
<site name="SomeSite" id="1">
<application path="/"
serviceAutoStartEnabled="true" serviceAutoStartProvider=”MyAutoStartProvider” />
</site>
</sites>
Posted
Oct 11 2009, 10:19 PM
by
Damir Dobric