473,480 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Testing reachability of WebRequest.Proxy for work / home app

Hi All,

I'm writing an app using WebRequest in csharp. I need the app to respond to
the host PC moving from one network to another, e.g. taking a laptop home
after work. Currently the WebRequest.Proxy is always picked up from the work
network settings, so that the GetResponse method throws a WebException when
the proxy is unreachable. But IE works fine across the two networks.

I've two questions.

1) Where is WebRequest getting the default proxy information from? I'd
assumed that it picked it up from IE's settings, but that doesn't explain
why IE makes the transition from work to home without problem while
WebRequest fails.

2) How do I test the reachability of the WebRequest.Proxy before calling
GetResponse? If I could test it first I could replace it with
GlobalProxySelection.GetEmptyWebProxy for the home network.

Cheers,

Tim.
Nov 17 '05 #1
1 3144
Tim Regan wrote:
Hi All,

I'm writing an app using WebRequest in csharp. I need the app to
respond to the host PC moving from one network to another, e.g.
taking a laptop home after work. Currently the WebRequest.Proxy is
always picked up from the work network settings, so that the
GetResponse method throws a WebException when the proxy is
unreachable. But IE works fine across the two networks.

I've two questions.

1) Where is WebRequest getting the default proxy information from?
I'd assumed that it picked it up from IE's settings, but that doesn't
explain why IE makes the transition from work to home without problem
while WebRequest fails.
Read this thread (it's somewhat messy):

http://tinyurl.com/48q9o
2) How do I test the reachability of the WebRequest.Proxy before
calling GetResponse? If I could test it first I could replace it with
GlobalProxySelection.GetEmptyWebProxy for the home network.


Unless the proxy's IP address is entered in your hosts file or you're
accessing it by IP address, the DNS lookup will already fail. So you
can try Dns.Resolve(), or if no DNS is involved, try to connect to the
proxy's HTTP port using (using Sockets, WebRequest, WebClient, ...).

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2

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

Similar topics

1
6940
by: Matthias Kwiedor | last post by:
I try to get a page from a https server. I can build up a connection with WebRequest and everything runs fine without setting a proxy. After setting a proxy, i get the error that i can't build a...
1
9989
by: Pete Davis | last post by:
First of all, I apologize. I wanted to post this in microsoft.public.dotnet.framework (as it's a bit more appropriate there), but Outlook Express is suddenly giving me errors whenever I go to that...
1
1210
by: DWrek | last post by:
Hi Everyone, I have a .NET dll that uses the HTTPWebRequest class to make an HTTP connection to an off-site server. This dll works just fine from a Winform but when I try to use it from an ASP...
4
7215
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server...
2
6451
by: davidcbrown | last post by:
I started using .NET 2003 and my first application is to parse an HTML form. But I am behind an ISA firewall and get "(407) Proxy Authentication Required" with the following code. The proxy...
6
12468
by: Jensen Bredhal | last post by:
Hello, I need to send command to a web server from a method. I understand this should be possible using the WebClient or WebRequest class. how can this be done? below an example of my...
5
3437
by: james.dixon | last post by:
Hi I have been struggling with what should be a simple thing. I want to crawl the web for specific links, and save any html and files that meet my criteria to my hard drive. I thought that...
2
5952
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
3
3586
by: archana | last post by:
Hi all, Can anyone tell me how to hide my Pc's IP address while sending webrequest. Is there only one way of using proxy to do this? If yes what if proxy server's IP address is blocked by...
0
7054
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
6918
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7057
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
7102
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
7003
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...
0
5357
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,...
0
4495
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
1310
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 ...
0
199
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...

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.