Hi there.
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:
to my web.config - this works fine.
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:
As the page I am trying to access requires authentication, I first capture the viewstate of the page. Once I have this I can then simulate a post of my login credentials and use a streamreader to retrieve the contents of the page.
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:
that I get the following error:
Could someone advise me as to whether I am defining the proxy correctly?
Thanks.
Ben
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:
Code:
<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:
Code:
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:
Code:
mywebRequest.GetResponse().Close()
The remote server returned an error: (407) Proxy Authentication Required.
Thanks.
Ben
Comment