webproxy settings for httpWebRequests

  • Thread starter Thread starter djc
  • Start date Start date
D

djc

I see many ways to accomplish setting up proxy settings for a web request in
the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my httpWebRequests within
a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class on an
individual basis, and I don't want to rely on the bypassLocal setting, or
the host exclusion list since I don't find those settings to be reliable in
IE itself.

2) mind as well ask since its related and I will probably want to do this at
some point. What is the current and correct way to tell an individual
httpWebReqest to *not* use any proxy?
 
djc,

By default, HttpWebRequest instances should be created without the Proxy
property being set. That is good enough.

Hope this helps.
 
thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy settings
by default. I have verified this with the following output right before
issuing the getResponse:
Console.WriteLine("current proxy is: {0}", myHTTPRequest.Proxy.GetProxy(new
Uri(_url)));



Nicholas Paldino said:
djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djc said:
I see many ways to accomplish setting up proxy settings for a web request
in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class on an
individual basis, and I don't want to rely on the bypassLocal setting, or
the host exclusion list since I don't find those settings to be reliable
in IE itself.

2) mind as well ask since its related and I will probably want to do this
at some point. What is the current and correct way to tell an individual
httpWebReqest to *not* use any proxy?
 
Ahh, it appears that by default, it returns the value from the static
Select method on the GlobalProxySelection class.

You can simply set the Proxy property to the value of the static
GetEmptyWebProxy method on the GlobalProxySelection class in order to
specify no proxy.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djc said:
thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy
settings by default. I have verified this with the following output right
before issuing the getResponse:
Console.WriteLine("current proxy is: {0}",
myHTTPRequest.Proxy.GetProxy(new Uri(_url)));



Nicholas Paldino said:
djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djc said:
I see many ways to accomplish setting up proxy settings for a web request
in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class on an
individual basis, and I don't want to rely on the bypassLocal setting,
or the host exclusion list since I don't find those settings to be
reliable in IE itself.

2) mind as well ask since its related and I will probably want to do
this at some point. What is the current and correct way to tell an
individual httpWebReqest to *not* use any proxy?
 
That is actually what prompted my post here because the GlobalProxySelection
class is marked obsolete in VS 2005 but there is no note as to what *should*
be used in it's place. I think I recall reading that you can create an
instance of the webProxy class without assigning a proxy address (keeping it
null) and assign that instance of the webProxy class to the
httpWebRequest.proxy property. Since the address is null it doesn't use the
proxy. I'm not sure though, and have not played with it. Even if that worked
I wanted to verify that it is what *should* be done. Again, VS documentation
stated that the GlobalProxySelection class is obsolete but did *not* state
what *should* be used. At least I didn't see it.

thanks again for the reply though. I do appreciate it.

Nicholas Paldino said:
Ahh, it appears that by default, it returns the value from the static
Select method on the GlobalProxySelection class.

You can simply set the Proxy property to the value of the static
GetEmptyWebProxy method on the GlobalProxySelection class in order to
specify no proxy.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djc said:
thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy
settings by default. I have verified this with the following output right
before issuing the getResponse:
Console.WriteLine("current proxy is: {0}",
myHTTPRequest.Proxy.GetProxy(new Uri(_url)));



Nicholas Paldino said:
djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I see many ways to accomplish setting up proxy settings for a web
request in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class on
an individual basis, and I don't want to rely on the bypassLocal
setting, or the host exclusion list since I don't find those settings
to be reliable in IE itself.

2) mind as well ask since its related and I will probably want to do
this at some point. What is the current and correct way to tell an
individual httpWebReqest to *not* use any proxy?
 
djc,
If you go ahead and use the obsolete code in your project and set a
breakpoint on it, I am sure the warning message will tell you what code to
use. I say this because I have seen it.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




djc said:
That is actually what prompted my post here because the GlobalProxySelection
class is marked obsolete in VS 2005 but there is no note as to what *should*
be used in it's place. I think I recall reading that you can create an
instance of the webProxy class without assigning a proxy address (keeping it
null) and assign that instance of the webProxy class to the
httpWebRequest.proxy property. Since the address is null it doesn't use the
proxy. I'm not sure though, and have not played with it. Even if that worked
I wanted to verify that it is what *should* be done. Again, VS documentation
stated that the GlobalProxySelection class is obsolete but did *not* state
what *should* be used. At least I didn't see it.

thanks again for the reply though. I do appreciate it.

Nicholas Paldino said:
Ahh, it appears that by default, it returns the value from the static
Select method on the GlobalProxySelection class.

You can simply set the Proxy property to the value of the static
GetEmptyWebProxy method on the GlobalProxySelection class in order to
specify no proxy.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

djc said:
thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy
settings by default. I have verified this with the following output right
before issuing the getResponse:
Console.WriteLine("current proxy is: {0}",
myHTTPRequest.Proxy.GetProxy(new Uri(_url)));



in message djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I see many ways to accomplish setting up proxy settings for a web
request in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class on
an individual basis, and I don't want to rely on the bypassLocal
setting, or the host exclusion list since I don't find those settings
to be reliable in IE itself.

2) mind as well ask since its related and I will probably want to do
this at some point. What is the current and correct way to tell an
individual httpWebReqest to *not* use any proxy?
 
ok, will do. Thanks.

Peter Bromberg said:
djc,
If you go ahead and use the obsolete code in your project and set a
breakpoint on it, I am sure the warning message will tell you what code to
use. I say this because I have seen it.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




djc said:
That is actually what prompted my post here because the
GlobalProxySelection
class is marked obsolete in VS 2005 but there is no note as to what
*should*
be used in it's place. I think I recall reading that you can create an
instance of the webProxy class without assigning a proxy address (keeping
it
null) and assign that instance of the webProxy class to the
httpWebRequest.proxy property. Since the address is null it doesn't use
the
proxy. I'm not sure though, and have not played with it. Even if that
worked
I wanted to verify that it is what *should* be done. Again, VS
documentation
stated that the GlobalProxySelection class is obsolete but did *not*
state
what *should* be used. At least I didn't see it.

thanks again for the reply though. I do appreciate it.

in
message news:[email protected]...
Ahh, it appears that by default, it returns the value from the
static
Select method on the GlobalProxySelection class.

You can simply set the Proxy property to the value of the static
GetEmptyWebProxy method on the GlobalProxySelection class in order to
specify no proxy.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy
settings by default. I have verified this with the following output
right
before issuing the getResponse:
Console.WriteLine("current proxy is: {0}",
myHTTPRequest.Proxy.GetProxy(new Uri(_url)));



"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in message djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I see many ways to accomplish setting up proxy settings for a web
request in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my
httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class
on
an individual basis, and I don't want to rely on the bypassLocal
setting, or the host exclusion list since I don't find those
settings
to be reliable in IE itself.

2) mind as well ask since its related and I will probably want to do
this at some point. What is the current and correct way to tell an
individual httpWebReqest to *not* use any proxy?
 
Error 1 Warning as Error: 'System.Net.GlobalProxySelection' is obsolete:
'This class has been deprecated. Please use WebRequest.DefaultWebProxy
instead to access and set the global default proxy. Use 'null' instead of
GetEmptyWebProxy.

Peter Bromberg said:
djc,
If you go ahead and use the obsolete code in your project and set a
breakpoint on it, I am sure the warning message will tell you what code to
use. I say this because I have seen it.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




djc said:
That is actually what prompted my post here because the
GlobalProxySelection
class is marked obsolete in VS 2005 but there is no note as to what
*should*
be used in it's place. I think I recall reading that you can create an
instance of the webProxy class without assigning a proxy address (keeping
it
null) and assign that instance of the webProxy class to the
httpWebRequest.proxy property. Since the address is null it doesn't use
the
proxy. I'm not sure though, and have not played with it. Even if that
worked
I wanted to verify that it is what *should* be done. Again, VS
documentation
stated that the GlobalProxySelection class is obsolete but did *not*
state
what *should* be used. At least I didn't see it.

thanks again for the reply though. I do appreciate it.

in
message news:[email protected]...
Ahh, it appears that by default, it returns the value from the
static
Select method on the GlobalProxySelection class.

You can simply set the Proxy property to the value of the static
GetEmptyWebProxy method on the GlobalProxySelection class in order to
specify no proxy.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

thanks for the reply Nicholas.

I am seeing a different behavior here. On my machine and another test
machine on the same network the httpWebRequest is using IE's proxy
settings by default. I have verified this with the following output
right
before issuing the getResponse:
Console.WriteLine("current proxy is: {0}",
myHTTPRequest.Proxy.GetProxy(new Uri(_url)));



"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote
in message djc,

By default, HttpWebRequest instances should be created without the
Proxy property being set. That is good enough.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I see many ways to accomplish setting up proxy settings for a web
request in the documentation but many of them are marked as obsolete.

1) What is the current and correct way to tell all my
httpWebRequests
within a class to *not* use any proxy server?

I don't want to setup the proxy on each webRequest within my class
on
an individual basis, and I don't want to rely on the bypassLocal
setting, or the host exclusion list since I don't find those
settings
to be reliable in IE itself.

2) mind as well ask since its related and I will probably want to do
this at some point. What is the current and correct way to tell an
individual httpWebReqest to *not* use any proxy?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top