salam Posted April 16, 2010 Posted April 16, 2010 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 Quote
Administrators PlausiblyDamp Posted April 16, 2010 Administrators Posted April 16, 2010 Could you not just set the web_request.Proxy property to an instance of the WebProxy class e.g. web.proxy = New WebProxy("< proxy address", ) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
salam Posted April 16, 2010 Author Posted April 16, 2010 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) Quote
Administrators PlausiblyDamp Posted April 16, 2010 Administrators Posted April 16, 2010 The code you posted should work just fine if you remove the ";" from the end of each line. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.