public bool UrlIsValid(string Url) { Stream sStream; WebRequest URLReq; WebResponse URLRes; try { URLReq = WebRequest.Create(Url); URLRes = URLReq.GetResponse(); sStream = URLRes.GetResponseStream(); string reader = new StreamReader(sStream).ReadToEnd(); return(true); } catch (SocketException se) { return(false); } }
private bool IsDomainURLOK() { bool flag = false; System.IO.Stream sStream; System.Net.HttpWebRequest URLReq; System.Net.HttpWebResponse URLRes; try { URLReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://" + txtDomainName.Text.ToLower().Replace("http://", "") + "/WebServices/GlobalWebService.asmx"); URLRes = (System.Net.HttpWebResponse)URLReq.GetResponse(); sStream = URLRes.GetResponseStream(); string reader = new System.IO.StreamReader(sStream).ReadToEnd(); flag = true; } catch (Exception ex) { flag = false; txtTest.Value += " " + ex.ToString(); //gClass.AddErrorLogData("0", "", Request.Url.Host, "IsDomainURLOK", "Add new/Update Organization", ex.ToString()); } return(flag); }