I need to know how I can detect the current application pool I am running under, so I can do a Recycle on it programmatically.
Does anyone know how to do this for IIS6?
My current code for recycling the app-pool is:
/// <summary> /// Recycle an application pool /// </summary> /// <param name='IIsApplicationPool'></param> public static void RecycleAppPool(string IIsApplicationPool) { ManagementScope scope = new ManagementScope(@'\\localhost\root\MicrosoftIISv2'); scope.Connect(); ManagementObject appPool = new ManagementObject(scope, new ManagementPath('IIsApplicationPool.Name='W3SVC/AppPools/' + IIsApplicationPool + '''), null); appPool.InvokeMethod('Recycle', null, null); }
And after searching I found the answer myself:
Hmm. They need a way to let me set my own answer as THE answer.