![]() ![]() If you don't pass the correct value to the SendPingAsync method, you will get a exception with the message No such host is known. Bonus tip: how to get the Hostname for a URLĪs I said, to perform a ping request you need to use only the hostname, and remove all the other parts of the URL, like the protocol, the query string and so on. ![]() And what about SendAsync? Well, it actually exists, but it requires different parameters and, even worse, it returns null instead of a PingReply object. Where is the SendPing method? It doesn't exist. The asynchronous method that we've used before is called SendPingAsync, but the synchronous method is called Send. I just want to point out that the library has a small discrepancy in the names for the methods. ![]() I won't repeat the example, it's almost identical to the one we've already seen. Well, there is also this possibility, but with a method called Send. We've seen how to ping an endpoint asynchronously. Private static async Task PingWithHttpClient ( ) The synchronous way ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |