我看到你使用了这项技术。网络微软。而且我认为您的网站和应用程序是使用“IIS”托管的?
您应该能够使用“ DirectoryEntry ”类及其多个属性。您可以像这样,检查托管在“ISS”上的网站或 Web 应用程序的状态,并检查应用程序池的状态。
要使用的命名空间:(在C#和ASPSystem.DirectoryServices上可用)
有关“DirectoryEntry”及其属性的更多信息:DirectoryEntry Info
像这样的东西:
//Get the webSite ID
public static int GetWebsiteID(string websiteName)
{
     string machineName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
     DirectoryEntry w3svc = new DirectoryEntry("IIS://"+machineName+"/w3svc");
     int id = 1;
     foreach(DirectoryEntry de in w3svc.Children)
     {
          if(de.SchemaClassName == "IIsWebServer" && de.Properties["ServerComment"][0].ToString() == websiteName)
           {
                id = int.Parse(de.Name);
           }
     }
     return id;
}
//Check statut of webSite
public void checkStatutWebSite()
{
     DirectoryEntry myWebSite = new DirectoryEntry(string.Format("IIS://" + machineName + "/w3svc/{0}/Root", GetWebsiteID("webSiteName")));
     ServerState state = (ServerState)Enum.Parse(typeof(ServerState), myWebSite.Properties["ServerState"].Value.ToString())
     if (state == ServerState.Stopped || state == ServerState.Paused)
     {
         //site is stopped
     }
}
public enum ServerState
{
    Unknown = 0,
    Starting = 1,
    Started = 2,
    Stopping = 3,
    Stopped = 4,
    Pausing = 5,
    Paused = 6,
    Continuing = 7
}
我希望这对你有帮助。