How to check if a web service is up and running without using ping?

后端 未结 8 921
小蘑菇
小蘑菇 2020-12-30 09:42

How can i check if a method in a web service is working fine or not ? I cannot use ping. I still want to check any kind of method being invoked from the web service by the c

8条回答
  •  时光说笑
    2020-12-30 10:12

    I use this method and it works fine :

    public bool IsAddressAvailable(string address)
    {
        try
        {
            System.Net.WebClient client = new WebClient();
            client.DownloadData(address);
            return true;
        }
        catch
        {
            return false;
        }
    }
    

提交回复
热议问题