私はあなたがその技術を使っているのを見ました。ネットマイクロソフト。そして、あなたのサイトとアプリケーションは「IIS」でホストされていると思いますか?
クラス「 DirectoryEntry」とその複数のプロパティを使用できるはずです。このように、「ISS」でホストされている Web サイトや Web アプリケーションの状態を確認したり、アプリケーション プールの状態を確認したりできます。
使用する名前空間: System.DirectoryServices
( C#およびASPで利用可能)
「DirectoryEntry」とそのプロパティの詳細: DirectoryEntry 情報
このようなもの:
//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
}
これがお役に立てば幸いです。