What\'s the easiest way in .NET to check what status code a web server replies with to a GET request?
Note that I do not need the body of the response. In fact, if possi
public HttpStatusCode GetHeaders(string url)
{
HttpStatusCode result = default(HttpStatusCode);
var request = HttpWebRequest.Create(url);
request.Method = "HEAD";
using (var response = request.GetResponse() as HttpWebResponse)
{
if (response != null)
{
result = response.StatusCode;
response.Close();
}
}
return result;
}