登入註冊 | 兩岸網 | 兩岸部落
2008-6-9
用c#怎么检测iis应用程序池是否被停止了,即它的状态
 static   void   ConfigAppPool()  
  {  
  try  
  {  
  ASCIIEncoding   encoding=new   ASCIIEncoding();  
  string   postData="TextBox1=33&Button1=Button";  
  byte[]     data   =   encoding.GetBytes(postData);  
   
  HttpWebRequest   myRequest   =(HttpWebRequest)WebRequest.Create("http://localhost/Forums/default.aspx");  
  myRequest.Method   =   "POST";  
  myRequest.ContentType="application/x-www-form-urlencoded";  
  myRequest.ContentLength   =   data.Length;  
  Stream   newStream=myRequest.GetRequestStream();  
  //   Send   the   data.  
  newStream.Write(data,0,data.Length);  
  newStream.Close();  
  }  
  catch  
  {  
  DirectoryEntry   appPool   =   new   DirectoryEntry("IIS://localhost/W3SVC/AppPools");  
  DirectoryEntry   findPool   =appPool.Children.Find("AppPoolForums","IIsApplicationPool");  
  findPool.Invoke("Start",null);  
  appPool.CommitChanges();  
  appPool.Close();  
  }  
  }  
   
  private   void   timer1_Tick(object   sender,   System.EventArgs   e)  
  {  
  ConfigAppPool();  
  }  
   
  private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
  timer1.Interval   =   8000;  
  timer1.Start();  
  }
 

該網誌共有 條回應

發表您的回應 »

請您先登入註冊,才能發表回應
 
行事曆
來訪記錄
13908 人訪問過您的Blog
E-Mail訂閱該Blog