Skip to content

Instantly share code, notes, and snippets.

@pushmon
Created February 22, 2012 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pushmon/1886168 to your computer and use it in GitHub Desktop.
Save pushmon/1886168 to your computer and use it in GitHub Desktop.
C#
using System;
using System.Net;
namespace TeamEXtension
{
public class UrlPing
{
public static void Main(string[] args)
{
string urlString = "http://pshmn.com/eaFnY";
try {
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(urlString);
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
}
catch (Exception e) {
// log error
}
}
}
}
@dpolistbpc
Copy link

dpolistbpc commented Apr 26, 2016

Simpler implementation:

public string Ping(string url)
{
    using (var webClient = new WebClient())
    {
        return webClient.DownloadString(url);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment