Keep in touch

you can keep in touch with my all blogs and sites by install this Toolbar...
http://rworldtoolbar.ourtoolbar.com/

Saturday, March 6, 2010

Check if Url Exists or not in ASP.NET

Public Shared Function IsValidUrl(ByVal Url As String) As Boolean
Dim sStream As Stream
Dim URLReq As HttpWebRequest
Dim URLRes As HttpWebResponse
Try
URLReq = WebRequest.Create(Url)
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
‘Url not valid
Return False
End Try
End Function

No comments: