[GH-ISSUE #127] C# usage example #87

Closed
opened 2026-02-25 23:41:07 +03:00 by kerem · 3 comments
Owner

Originally created by @cuu508 on GitHub (Jul 19, 2017).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/127

using (var client = new System.Net.WebClient())
{
       client.DownloadString("ping url");
}

I know nothing about C#. Does the above look OK?

Originally created by @cuu508 on GitHub (Jul 19, 2017). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/127 ``` using (var client = new System.Net.WebClient()) { client.DownloadString("ping url"); } ``` I know nothing about C#. Does the above look OK?
kerem closed this issue 2026-02-25 23:41:07 +03:00
Author
Owner

@taylus commented on GitHub (Aug 3, 2017):

For pinging a check? Yeah, that's the way to do it.

There's a newer class called HttpClient which you might see around, but it's not a straight replacement and both are still widely used.

http://www.diogonunes.com/blog/webclient-vs-httpclient-vs-httpwebrequest/
https://stackoverflow.com/questions/20530152/need-help-deciding-between-httpclient-and-webclient

Its use would look very similar:

using (var client = new HttpClient())
{
    await client.GetAsync("ping url");
}
<!-- gh-comment-id:320094059 --> @taylus commented on GitHub (Aug 3, 2017): For pinging a check? Yeah, that's the way to do it. There's a newer class called HttpClient which you might see around, but it's not a straight replacement and both are still widely used. http://www.diogonunes.com/blog/webclient-vs-httpclient-vs-httpwebrequest/ https://stackoverflow.com/questions/20530152/need-help-deciding-between-httpclient-and-webclient Its use would look very similar: <pre> using (var client = new HttpClient()) { await client.GetAsync("ping url"); } </pre>
Author
Owner

@rud commented on GitHub (Sep 11, 2017):

Looks legit, issue seems possible to close now?

<!-- gh-comment-id:328472427 --> @rud commented on GitHub (Sep 11, 2017): Looks legit, issue seems possible to close now?
Author
Owner

@cuu508 commented on GitHub (Sep 11, 2017):

Yeah, I'll add an usage example and close this issue when that's done.

<!-- gh-comment-id:328476032 --> @cuu508 commented on GitHub (Sep 11, 2017): Yeah, I'll add an usage example and close this issue when that's done.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#87
No description provided.