Last post Sep 02, 2012 10:50 PM by colol
Member
116 Points
477 Posts
Aug 06, 2012 11:31 PM|colol|LINK
Anyone know how to do a simple function where if the url link given exists simply output website is found and if not website is not found??
url c-sharp
Contributor
2151 Points
513 Posts
Aug 07, 2012 12:16 PM|MattsDotNetUsername|LINK
Something like this should work:
protected void Page_Load(object sender, EventArgs e) { Response.Write(IsLinkValid(new Uri("http://www.asp.net"))); Response.Write("<br />"); Response.Write(IsLinkValid(new Uri("http://www.asp.net/ThisDoesNotExist"))); Response.Write("<br />"); } private Boolean IsLinkValid(Uri uri) { try { WebRequest request = WebRequest.Create(uri); request.Method = "HEAD"; WebResponse r = request.GetResponse(); return true; } catch (WebException) { return false; } }
Sep 02, 2012 10:50 PM|colol|LINK
Thankyou for the coding but when i run the coding, both output False....
Member
116 Points
477 Posts
Simply check whether url link active or not
Aug 06, 2012 11:31 PM|colol|LINK
Anyone know how to do a simple function where if the url link given exists simply output website is found and if not website is not found??
url c-sharp
Contributor
2151 Points
513 Posts
Re: Simply check whether url link active or not
Aug 07, 2012 12:16 PM|MattsDotNetUsername|LINK
Something like this should work:
url c-sharp
Member
116 Points
477 Posts
Re: Simply check whether url link active or not
Sep 02, 2012 10:50 PM|colol|LINK
Thankyou for the coding but when i run the coding, both output False....
url c-sharp