13 November 2014

If you, like me, like to encapsulate jobs in the IIS app pool, as opposed to creating scheduled tasks in Windows Task Scheduler you’ve most likely faced the same issues as I with your application pool shutting down after being inactive for some time. Read on for a guide on how to configure IIS 7.5 for having always running and auto starting app pools.

This post was inspired by the slew of posts on various blogs describing how you can configure IIS Application Initialization under IIS 8, leaving out how to do it in IIS 7.5. You see, in IIS 8 it’s a feature that can be added under “Turn Windows features on or off,” but that’s not the case with IIS 7.5, here it has to be installed through Web Platform Installer. Further complicating things this module differs from the IIS 8 version in that it doesn’t include the configuration component for IIS Manager, leaving you with editing the applicationHost.config file manually, not exactly ideal. And it’s not too well documented either. After some searching I found a guy who did his own snap-in for IIS manager, and it functions very well. Credits go where credits due, and the guy I’m referring to can be found here: MSDN Social.

The first you’d want to do, is to set the timeout of the application pool to 0 (indefinite) like so, default is 20 minutes:

Here’s a snapshot of how the application level tab of the snap-in looks like.

Here’s an example of how a working application level configuration could look like.

1
2
3
4
5
6
7
8
9
<configuration>
	<system.applicationHost>
        <applicationPools>
            <add name="DefaultAppPool" autoStart="true" managedRuntimeVersion="v4.0" startMode="AlwaysRunning">
                <processModel identityType="ApplicationPoolIdentity" idleTimeout="00:00:00" />
            </add>
        </applicationPools>
	</system.applicationHost>
</configuration>

And the path for this file is:

%windir%\System32\inetsrv\config\applicationHost.config

Here’s a screenshot of how the website level tab of the snap-in looks like.

And here’s an example of how a working website level configuration could look like.

1
2
3
4
5
6
7
<configuration>
	<system.webServer>
		<applicationInitialization remapManagedRequestsTo="" skipManagedModules="false" doAppInitAfterRestart="true">
			<add initializationPage="/" />
		</applicationInitialization>
	</system.webServer>
</configuration>

You can verify everything works as intended by manually killing your worker process (w3wp.exe) and see it how it will immediately spool back up, that’s all there is to it. Happy configuring.

Here’s the link for downloading the installer for Application Initialization for IIS 7.5 over at Microsoft, and I’ve provided a mirror for the installer here: Mirror.

Here’s the link for downloading the installer for the custom configuration snap-in over at MSDN Blogs, and a mirror is provided here: Mirror.