c# web requests + proxies

Onions

Newbie
Joined
May 13, 2003
Messages
849
Reaction score
0
lo my lovelys! making a c# app, doing a http get. and having problems getting it to go through my proxy. it works fine on other isp's, but mine (freeserve) have this page that gets sent instead of what you request to tell you to update your proxy settings in IE.

Here's the code in question..
Code:
string URL = "http://www.i-fighter.co.uk/txt.txt"; // grab some random shit for testage
			WebRequest request;
			request = WebRequest.Create(URL);
			if (Proxy == true)
			{
				WebProxy myProxy = new WebProxy("bleh",0); // feed it crap, it gets the clients settings from IE
				myProxy.BypassProxyOnLocal = true;
				request.Proxy = WebProxy.GetDefaultProxy(); // get proxy settings from IE
				
			}

only things you need to know is "Proxy" is a bool, and yes it's true :)
also the proxy is correctly set up in ie

any suggestions?
 
hippy! thats all fine and good but what about other freeserve users? :)
 
Round them up and beat them soundly with a large rusty spike.
 
all freeserver users smell, FACT!!!

however, have you checked that the proxy settings are getting set right in that proxy object?
 
ok, i'm a fool, heh. Updated code that actually works, but with another problem - it can't find the proxy :eek:

Code:
			string URL = "http://www.i-fighter.co.uk/txt.txt"; // grab some random shit for testage
			WebRequest request;
			request = WebRequest.Create(URL);
			if (Proxy == true)
			{
				WebProxy myProxy = new WebProxy("http://www-cache.freeserve.com/",8080); // freeserve proxy address, for testing
				myProxy.BypassProxyOnLocal = true;
				request.Proxy = myProxy;
				output.Text = output.Text + myProxy.Address.ToString();	
			}
 
gives an unhandled exception
"System.Net.WebException: The underlying connection was closed: The proxy name could not be resolved, verify correct proxy configuration."
 
so i asusme that output.Text has the value you pass in it?.. or not as the above post shows...

have you tried it sans http:// in the address?
 
output is a textlabel i'm using to spit out the stream for testing :)
will try that, and stop using crazy words! :D
 
it doesnt get to changing output.Text, it fluffs up when it trys to create the proxy and fails
 
rofl, i removed the http from the url i'm grabbing, heh. works now, cheers rob :)
 
heh, pld :p
the question is, will it still work when no proxy is involved without the http?
hmm i would guess yes coz of the object involved...

btw, i guessed about the no changing the output.Text thingy as exceptions break the program before it gets there (btw, you should trap that to handle it gracefully), C++ has 'em as well ya know :p
 
Back
Top