简体   繁体   中英

IIS7 Application Pools in C#

I have a web application that is hosted locally via IIS7 on each PC it is installed. Inside the web application, an administrator can change settings. One of those settings includes App Pool IdleTimout. The C# code is working as far as I can tell using the Microsoft.Web.Administration.dll reference: (A short example)

ServerManager manager = new ServerManager();
manager.ApplicationPools["DefaultAppPool"].ProcessModel.IdleTimeout = new TimeSpan(0, 5, 0);

While debugging the code, IdleTimeout is showing a value of {00:05:00} which should be correct per the code above.

However, if I go into IIS after this setting has been updated and saved, and go to the Advanced Settings section of the DefaultAppPool, I see the timeout is still set to the default 20. Is this supposed to change in IIS when I set the variable like I am above? I've been doing a lot of Googling this afternoon, but I can't seem to find an answer to this. Hopefully I'm just doing something wrong. Any insight is greatly appreciated! My goal is to be able to set the DefaultAppPool's IdleTimeout inside C# code.

You need to call CommitChanges() on your ServerManager instance after you make changes.

ServerManager manager = new ServerManager();
manager.ApplicationPools["DefaultAppPool"].ProcessModel.IdleTimeout = new TimeSpan(0, 5, 0);
manager.CommitChanges();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM