若是不用組件,能夠用下列方法:url
public bool IsWebServiceAvaiable(String url) { try { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); using(HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse()) { return true; } } catch (WebException e) { if (e.Status == WebExceptionStatus.ProtocolError) { XXX.LogMessage(String.Format("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode)); XXXX.LogMessage(String.Format("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription)); } } catch (Exception e) { XXX.LogMessage(e.Message); } return false; }