I have written a screen scraping application (both web based and windows forms) in vb.net. When testing on a public broadband link it works fine. However it fails at work due to our proxy server.
To authenticate in the asp version, I just added:
Expand|Select|Wrap|Line Numbers
- <defaultProxy useDefaultCredentials="true">
However, I need to integrate this with an existing windows form app (vb6) so need to get the windows form version working.
I am struggling to achieve the same settings (as per web.config) directly within my code. This is what I am trying to use so far:
Expand|Select|Wrap|Line Numbers
- Dim mywebRequest As HttpWebRequest = TryCast(WebRequest.Create("http://www.thedomain.com/login.aspx"), HttpWebRequest)
- mywebRequest.Proxy = New WebProxy("http://myproxyserver")
- mywebRequest.Proxy.Credentials = CredentialCache.DefaultCredentials
- mywebRequest.Credentials = CredentialCache.DefaultCredentials
Click here for a C# tutorial.
The thing I dont understand is that the first part of the code appears to work (and passes through the proxy). It is only when i try and close the contents of the response:
Expand|Select|Wrap|Line Numbers
- mywebRequest.GetResponse().Close()
The remote server returned an error: (407) Proxy Authentication Required.Could someone advise me as to whether I am defining the proxy correctly?
Thanks.
Ben