private void StatusDescription_Click(object sender, System.EventArgs e)
       {
           PageUrl = UrlText.Text;
           try 
           {   
               HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(PageUrl); 
               myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials;
               HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); 
               if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
               {
                   ContentHtml.Text = "Response Status Code is OK and StatusDescription is: "+myHttpWebResponse.StatusDescription;
               }
               myHttpWebResponse.Close(); 
       
           } 
           catch(WebException ee) 
           {
               ContentHtml.Text = "WebException Raised. The following error occured : "+ee.Status; 
           }
           catch(Exception ee)
           {
               ContentHtml.Text = "The following Exception was raised : "+ee.Message;
           }
       }

相关文章:

  • 2021-06-15
  • 2022-02-19
  • 2022-01-16
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2021-06-14
  • 2021-08-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
相关资源
相似解决方案