Created
October 29, 2014 15:17
-
-
Save csdear/a7b2eddd1be7fdcec11a to your computer and use it in GitHub Desktop.
HTTP : Get HTTP StatusCode Response Description. Params : HTTP url string
Method returns the the HTTP StatusCode Description e.g. 'OK'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String GetHttpResponse(string url) | |
{ | |
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("http://" + url); | |
//webRequest.AllowAutoRedirect = false; | |
HttpWebResponse response = (HttpWebResponse) webRequest.GetResponse(); | |
response.Close(); | |
return response.StatusCode.ToString(); | |
} | |
//*** | |
//Example call to method | |
string response = httpAliveUrl; | |
var httpAliveResponse = GetHttpResponse(response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment