Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool UrlAvailable(this string httpUrl)
- {
- if (!httpUrl.StartsWith("http://") || !httpUrl.StartsWith("https://"))
- httpUrl = "http://" + httpUrl;
- try
- {
- HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(httpUrl);
- myRequest.Method = "GET"
- myRequest.ContentType = "application/x-www-form-urlencoded"
- HttpWebResponse myHttpWebResponse =
- (HttpWebResponse)myRequest.GetResponse();
- return true;
- }
- catch
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment