标签:des http io os sp on bs ef as
String PageUrl = "url";
try
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(PageUrl);
myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
{
LabelMessage.Text="Response Status Code is OK and StatusDescription is: "+myHttpWebResponse.StatusDescription;
}
myHttpWebResponse.Close();
}
catch(WebException ee)
{
LabelMessage.Text = "WebException Raised. The following error occured : " + ee.Status;
}
catch(Exception ee)
{
LabelMessage.Text = "The following Exception was raised : " + ee.Message;
}
标签:des http io os sp on bs ef as
原文地址:http://www.cnblogs.com/yixingmeng/p/4111372.html