473,503 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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.

Nov 16 '05 #1
3 6116
Hi aviv,

You'll need to use the CookieCollection property.
I have an example in this article:

http://odetocode.com/Articles/162.aspx

--s

On Mon, 19 Jul 2004 05:26:01 -0700, "avivgur"
<av*****@discussions.microsoft.com> wrote:
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.


--
Scott
http://www.OdeToCode.com
Nov 16 '05 #2
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" <av*****@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...
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.

Nov 16 '05 #3
Hi aviv,

Apologies, I posted a reply meant for a different thread.

I meant to say:
You can use static memebers of GlobalProxySelection to force all web
requests through a proxy server.

See http://odetocode.com/Blogs/scott/arc...06/29/290.aspx

--s
--
Scott
http://www.OdeToCode.com
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2381
by: Fuzzyman | last post by:
I'm trying to create a proxy server - one that will modify requests made through it. I've started with Tiny HTTP Proxy by SUZUKI Hisao which is built on BaseHTTPServer - and I'm starting to get...
4
17634
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
1
5947
by: David Lojudice S. | last post by:
1
12266
by: Imran Aziz | last post by:
Hello All, I am using HttpWebRequest to fetch webpages in my ASP.net C# application. The request works fine without the proxy, but on using the code from within a network that uses proxy the...
9
3441
by: Codex Twin | last post by:
I am re-sending this in the hope that it might illicit a response. I have a corporate client who forces their workstations to get the proxy server details using an automatic proxy discovery script....
2
4579
by: pradeep_TP | last post by:
I am new to web services. I created a very simple web service with a method that returns a simple string object. I added a web reference to this web service from another project and I could...
2
11401
by: rcp | last post by:
Hi all, I've read all posts from all existing threads and none of them worked to solve my problem, although its exactly the same. I'll try to explain my case and see if a kind soul could help me...
2
9407
by: master | last post by:
Hi, I was using the FtpWebRequest class in .NET 2.0 for an FTP transport over SSL. It is working well, however the new requirement for my application is to tranfer files via an HTTP proxy. The...
2
8116
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.