Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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
dpolistbpc commented Apr 26, 2016 edited

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