Disable IIS Idle Timeouts in Azure Web Role

后端 未结 6 2047
-上瘾入骨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:06

    In the root of your Web Application Project, create a file named WebRole.cs with the following code:

    public class WebRole : RoleEntryPoint
    {
        public override void Run()
        {
            RemoveIISTimeouts();
            base.Run();
        }
    
        private void RemoveIISTimeouts()
        {
            Process.Start(
                String.Format(@"{0}\system32\inetsrv\appcmd", Environment.GetEnvironmentVariable("windir")),
                "set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00");
        }
    }
    

提交回复
热议问题