你可以尝试这种方法..
public bool IsAddressAvailable(string address)
{
try
{
using(System.Net.WebClient client = new WebClient())
{
client.DownloadData(address);
return true;
}
}
catch
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
......并称之为......
MessageBox.Show(IsAddressAvailable("http://localhost/my.webservices/mywebservice.asmx").ToString());
Run Code Online (Sandbox Code Playgroud)