How do I open a URL (via a proxy) for reading?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am trying to implement a simple windows application that reads from a specified url.
Currently am using the WebClient class to access the url and the OpenRead() member to retrieve a readable stream which I then read with a StreamReader.
This works fine for url within my domain.
The problem starts when I try to access url's outside my domain (such as www.yahoo.com). When I do this the connection times out. Obviously I need to connect through a proxy. However, I found no way to define a proxy for the WebClient class. (The WebRequest class has a Proxy property but it does not have a method to retrieve streams for READING).
What should I do?
Aviv.
 
You can set the proxy used by the WebClient class by using the
GlobalProxySelection.Select object. As for using WebRequest, you're correct
this object has no methods for reading -- those methods are found on the
WebResponse class. Once you have your WebRequest object, call GetResponse()
and then use GetResponseStream() on the returned object to read the response
data.

Ken


avivgur said:
Hello,
I am trying to implement a simple windows application that reads from a specified url.
Currently am using the WebClient class to access the url and the
OpenRead() member to retrieve a readable stream which I then read with a
StreamReader.
This works fine for url within my domain.
The problem starts when I try to access url's outside my domain (such as
www.yahoo.com). When I do this the connection times out. Obviously I need
to connect through a proxy. However, I found no way to define a proxy for
the WebClient class. (The WebRequest class has a Proxy property but it does
not have a method to retrieve streams for READING).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top