如何在asp.net2.0中重启aspnet_state服务
以下是1.1中的代码,但在2.0中不能用了:using System.ServiceProcess;
public void ResetAspNetService()
{
ServiceController sc = new ServiceController("aspnet_state");
if (sc.Status == ServiceControllerStatus.Running)
{
sc.Stop();
sc.WaitForStatus(ServiceControllerStatus.Stopped); //等待服务停止
if (sc.Status == ServiceControllerStatus.Stopped)
{
sc.Start();
}
}
else
{
sc.Start();
}
}