要使用ASP.NET 4自動啟動特性,你首先配置IIS應用池工作進程,使在其中運行的應用在web服務器最先裝載時即自動啟動。配置方法是,打開IIS 7.5的applicationHost.config文件(C:\Windows\System32\inetsrv\config\applicationHost.config),在合適的<applicationPools>中加一個 startMode=”AlwaysRunning”屬性:
<applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>
<add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>