Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 couldn�t get the connection of proxy.

 

I�m 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

Posted

thanks you sir,

You mean make class??

 

Any One can convert this codes to VB.NET??

This code in ASP.NET and i think they will help me to specify user name and password

//set the proxy for the SQU proxy server so that u can access website outside SQU

myHttpWebRequest.Proxy = WebProxy.GetDefaultProxy();

myHttpWebRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;

myHttpWebRequest.Proxy.Credentials = new System.Net.NetworkCredential(SQUlogin, SQUpassword)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...