如果您使用的是IIS7,那么如果它已停止,則會執(zhí)行此操作。我假設你可以調整重啟而不必顯示。
// Gets the application pool collection from the server.[ModuleServiceMethod(PassThrough = true)]public ArrayList GetApplicationPoolCollection(){
// Use an ArrayList to transfer objects to the client.
ArrayList arrayOfApplicationBags = new ArrayList();
ServerManager serverManager = new ServerManager();
ApplicationPoolCollection applicationPoolCollection = serverManager.ApplicationPools;
foreach (ApplicationPool applicationPool in applicationPoolCollection)
{
PropertyBag applicationPoolBag = new PropertyBag();
applicationPoolBag[ServerManagerDemoGlobals.ApplicationPoolArray] = applicationPool;
arrayOfApplicationBags.Add(applicationPoolBag);
// If the applicationPool is stopped, restart it.
if (applicationPool.State == ObjectState.Stopped)
{
applicationPool.Start();
}
}
// CommitChanges to persist the changes to the ApplicationHost.config.
serverManager.CommitChanges();
return arrayOfApplicationBags;}
如果您使用的是IIS6,我不太確定,但您可以嘗試獲取web.config并編輯修改日期或其他內容。對web.config進行編輯后,應用程序將重新啟動。