IIS7 Application Pools in C #

I have a web application that is hosted locally through IIS7 on every PC installed. Inside the web application, the administrator can change the settings. One of these settings includes the App Pool IdleTimout. C # code works, as far as I can tell, using the link Microsoft.Web.Administration.dll: (brief example)

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

When debugging the code, IdleTimeout shows the value {00:05:00}, which should be correct for the code above.

However, if I go to IIS after this parameter has been updated and saved, and go to the "Advanced Settings" section of DefaultAppPool, I see that the timeout is still set to the default value of 20. Is this supposed to change in IIS, when I set a variable, how am I above? Today I have a lot of googling, but I can not find the answer to this question. Hope I'm just doing something wrong. Any insight is greatly appreciated! My goal is to set DefaultAppPool IdleTimeout inside C # code.

+4
source share
1 answer

You need to call CommitChanges() on your ServerManager instance after making the changes.

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

Source: https://habr.com/ru/post/1500805/


All Articles