hii
Please, I need help if it's possible. I have project.
I ask user to enter URLs. So, I must to check if those URLs are valid or not.
I want to specify the proxy of my university to able check validity of URLs. Those codes not work at my university and that's becuse proxy. I trying a lot but I couldnt get the connection of proxy.
Im working in VB.Net not in ASP.Net
Proxy : 80
Please replay as soon as possible.
Thank you a lot ..
Sincerely,
Import System.Net
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim proxyObject As New WebProxy("http://webproxy:80/", True)
'Dim req As WebRequest = WebRequest.Creat("http://www.contoso.com")
'req.Proxy = proxyObject
If UrlIsValid(txtURL.Text) Then
MessageBox.Show("URL is valid")
Else
MessageBox.Show("URL is not valid")
End If
End Sub
Private Function UrlIsValid(ByVal url As String) As Boolean
Dim is_valid As Boolean = False
If url.ToLower().StartsWith("www.") Then url = "http://" & url
Dim web_response As HttpWebResponse = Nothing
Try
Dim web_request As HttpWebRequest = HttpWebRequest.Create(url)
web_response = DirectCast(web_request.GetResponse(), HttpWebResponse)
Return True
Catch ex As Exception
Return False
Finally
If Not (web_response Is Nothing) Then web_response.Close()
End Try
End Function
End Class
Please, I need help if it's possible. I have project.
I ask user to enter URLs. So, I must to check if those URLs are valid or not.
I want to specify the proxy of my university to able check validity of URLs. Those codes not work at my university and that's becuse proxy. I trying a lot but I couldnt get the connection of proxy.
Im working in VB.Net not in ASP.Net
Proxy : 80
Please replay as soon as possible.
Thank you a lot ..
Sincerely,
Import System.Net
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Dim proxyObject As New WebProxy("http://webproxy:80/", True)
'Dim req As WebRequest = WebRequest.Creat("http://www.contoso.com")
'req.Proxy = proxyObject
If UrlIsValid(txtURL.Text) Then
MessageBox.Show("URL is valid")
Else
MessageBox.Show("URL is not valid")
End If
End Sub
Private Function UrlIsValid(ByVal url As String) As Boolean
Dim is_valid As Boolean = False
If url.ToLower().StartsWith("www.") Then url = "http://" & url
Dim web_response As HttpWebResponse = Nothing
Try
Dim web_request As HttpWebRequest = HttpWebRequest.Create(url)
web_response = DirectCast(web_request.GetResponse(), HttpWebResponse)
Return True
Catch ex As Exception
Return False
Finally
If Not (web_response Is Nothing) Then web_response.Close()
End Try
End Function
End Class