Disable IIS Idle Timeouts in Azure Web Role

后端 未结 6 2035
-上瘾入骨i
-上瘾入骨i 2020-12-23 22:02

To prevent AppPool recycling every 20 minutes, I\'d like to remove IIS AppPool Idle Timeouts when my Azure Web Role starts. My website is a Web Application Project.

6条回答
  •  天命终不由人
    2020-12-23 22:14

    This is the approach I took:

    using (ServerManager iisManager = new ServerManager())
    {
        Application app = iisManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"].Applications[0];
    
        TimeSpan ts = new TimeSpan(0, 00, 00);
    
        iisManager.ApplicationPoolDefaults.ProcessModel.IdleTimeout = ts;
    
        iisManager.CommitChanges();
    }
    

    Requires:

    using Microsoft.Web.Administration;
    using Microsoft.WindowsAzure.ServiceRuntime;
    

提交回复
热议问题