473,657 Members | 2,993 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 6122
Hi aviv,

You'll need to use the CookieCollectio n 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*****@discus sions.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
GlobalProxySele ction.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 GetResponseStre am() on the returned object to read the response
data.

Ken
"avivgur" <av*****@discus sions.microsoft .com> wrote in message
news:BB******** *************** ***********@mic rosoft.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 GlobalProxySele ction 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
2399
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 somewhere. It listens on local ports and tells you whats goign through it. I'm in a slightly unusual situation though - all internet traffic goes through a proxy - I have to set the proxy settings to dav-serv:8080 to work.
4
17691
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 need to make a socket connection through it. The reason (with code example) is as follows : I am hacking "Tiny HTTP Proxy" by SUZUKI Hisao to make an http proxy that modifies URLs. I haven't got very far - having started from zero knowledge of...
1
5954
by: David Lojudice S. | last post by:
1
12294
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 request does not work. I tried to use the MS code to get around it, but having problems using it. The first thing is that the this conversion myProxy=(WebProxy)myWebRequest.Proxy; does not work, and I get an error of cannot convert...
9
3445
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. Unfortunately, the .NET Framework does not support automatic proxy discovery scripts. See: http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;307220 The article above details that the way to workaround this is to edit the...
2
4582
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 successfully call the method. Now, I want to understand why many suggests to create a proxy object of the web service and then call the method using this proxy object. What is the difference between creating a proxy object using WSDL utility and...
2
11422
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 out: I've a win32 service in C# on a client machine A, which accesses a WS (C#) on a server machine B (hosted on an IIS) Case 1: If I try to add the WSDL for the WS through VS2005, the 'Discovery
2
9424
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 FtpWebRequest class supports such a proxy, however, the documentation states that the FTP client can only download files and list directories (so the transfer is read-only). The problem is that the application is transferring files both ways - to...
2
8158
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 407 Proxy Authentication Required. The same request through the old proxy succeeds. The same request to an HTTP address through the new proxy succeeds. Also, the request succeeds when forced to use Basic authentication but fails on NTLM.
0
8384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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 we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.