要使用ASP.NET 4自动启动特性,你首先配置IIS应用池工作进程,使在其中运行的应用在web服务器最先装载时即自动启动。配置方法是,打开IIS 7.5的applicationHost.config文件(C:WindowsSystem32inetsrvconfigapplicationHost.config),在合适的<applicationPools>中加一个 startMode=”AlwaysRunning”属性:
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>