HTTP Classes

  • Thread starter Thread starter yoni
  • Start date Start date
Y

yoni

Hi All,
I am using .net classes to download files over HTTP. in the old world,
I would use WinInet, and the good think about that was that if the
client was behind a proxy, it would already use IE settings
automaticaly, and the communication would go smooth. in .NET, i have
to make the users enter proxy info (URL, port, sometimes password)

is there any way in .NET to have it use the exesting IE setup on a
local computer for web communication, just like with the old WinInet?

thanks
 
I am using .net classes to download files over HTTP. in the old world,
I would use WinInet, and the good think about that was that if the
client was behind a proxy, it would already use IE settings
automaticaly, and the communication would go smooth. in .NET, i have
to make the users enter proxy info (URL, port, sometimes password)

is there any way in .NET to have it use the exesting IE setup on a
local computer for web communication, just like with the old WinInet?

WebClient and HttpWebRequest use the same proxy as IE by default, IIRC.
 
Hi Jon,
I dont think HttpWebRequest does. are you sure? Over here it sure
doesnt, at least not by default. check out this code sample, which is
one out of many given by Microsoft:

HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);

//handle proxy, if given
if (sProxy.Length>0)
{
WebProxy proxyObject;
if (iProxyPort==0)
proxyObject = new WebProxy(sProxy);
else
proxyObject = new WebProxy(sProxy, iProxyPort);
Request.Proxy = proxyObject;
}


see? my do i need to set proxy explicitly? i am 100% that if i wont
set those, my code wont work when i am behind a proxy. if i get the IE
settings and put them into those variables (sProxy, iProxyPort) than
lo and behold, it would work....

thanks
 
I dont think HttpWebRequest does. are you sure? Over here it sure
doesnt, at least not by default. check out this code sample, which is
one out of many given by Microsoft:

HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);

//handle proxy, if given
if (sProxy.Length>0)
{
WebProxy proxyObject;
if (iProxyPort==0)
proxyObject = new WebProxy(sProxy);
else
proxyObject = new WebProxy(sProxy, iProxyPort);
Request.Proxy = proxyObject;
}


see? my do i need to set proxy explicitly? i am 100% that if i wont
set those, my code wont work when i am behind a proxy. if i get the IE
settings and put them into those variables (sProxy, iProxyPort) than
lo and behold, it would work....

Hmm... I was sure that it did on at least the Compact Framework, as we
had to work round that in a product I worked on ages ago.

In .NET 2.0, WebRequest.GetDefaultProxy() has been obsoleted, saying
that you should "use the proxy selected for you by default".

Are you using 1.1 or 2.0?
 
Hey,
I am using .NET 2.0; so far, form what i read the method is not
needed... it does this by default... right? my understanding is that
it works only for nondynamic proxies. (right?) is there any way to
use IE settings, even when they are dynamic? thanks
 
Thus wrote (e-mail address removed),
Hey,
I am using .NET 2.0; so far, form what i read the method is not
needed... it does this by default... right? my understanding is that
it works only for nondynamic proxies. (right?)

That was true for System.Net 1.x.
is there any way to
use IE settings, even when they are dynamic? thanks

That feature has been added in System.Net 2.0. Are you using a .pac file?

Cheers,
 
That feature has been added in System.Net 2.0. Are you using a .pac file?

I dont know what the customer is using. many download my utility, each
one has a different proxy settings. I am looking for the solution that
will work with whatever they have... static (thats easy, .net2.0 does
this by default) pac file, DHCP...
 
Thus wrote (e-mail address removed),
I dont know what the customer is using. many download my utility, each
one has a different proxy settings. I am looking for the solution that
will work with whatever they have... static (thats easy, .net2.0 does
this by default) pac file, DHCP...

Why not include an application specific proxy setting that users can apply
if autodetection seems to fail?

Cheers,
 
Why not include an application specific proxy setting that users can apply
if autodetection seems to fail?


that is a good idea, and we do that. but most users haven't even heard
of proxy, and those who are and are not lazy cant even put the data
in... because its in some script file or something and IT wont give it
to them. You helped me a lot by pointing out the .net 2.0 has auto
detect automatically. now the last thing i need to know is: what does
auto detect detects? it does static proxy that's set up in IE', thats
good. what about dynamic ones? if its in a PAC file, will it detect
it? for example there are all those postings online on how to do API
calls to WinINet (mostly with function WinHttpGetProxyForUrl, but also
with others) who will help you with dynamic proxies - is that still
needed with .net 2.0, or is it built in to the .net now, and calls to
wininet would be superfluous?
 
Thus wrote (e-mail address removed),
that is a good idea, and we do that. but most users haven't even heard
of proxy, and those who are and are not lazy cant even put the data
in... because its in some script file or something and IT wont give it
to them. You helped me a lot by pointing out the .net 2.0 has auto
detect automatically. now the last thing i need to know is: what does
auto detect detects? it does static proxy that's set up in IE', thats
good. what about dynamic ones? if its in a PAC file, will it detect
it?

Yes to .PAC.
for example there are all those postings online on how to do API
calls to WinINet (mostly with function WinHttpGetProxyForUrl, but also
with others) who will help you with dynamic proxies - is that still
needed with .net 2.0, or is it built in to the .net now, and calls to
wininet would be superfluous?

WinHttpGetProxyForUrl AFAIK implements WPAD as System.Net 2.0 does -- it
shouldn't be necessary to use that.

http://msdn.microsoft.com/msdnmag/issues/05/08/AutomaticProxyDetection/default.aspx
explains the System.Net 2.0 implementation.

Cheers,
 
Back
Top