C# .NET app does not respect IE proxy settings

G

Guest

posting this again as : (e-mail address removed)

We have a C# .NET app which runs as a service.
It posts data to a server using HttpWebrequest.
According to the docs I 've read, it should use the proxy settings from IE
on the server machine. But it doesn't, it always posts straight to the
server.
I tried forcing it by doing this:

WebProxy defaultProxy = WebProxy.GetDefaultProxy();
webRequest.Proxy = defaultProxy;

But that doesn't seem to make it use the proxy settings either.
On the flip side, a client I have which calls webservices DOES respect the
proxy settings without my ever telling it to do so.
How do I get the HttpWebRequest to respect the IE proxy settings?

thanks
Robb
 
K

Kevin Yu [MSFT]

Hi Robb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the default IE proxy
setting. If there is any misunderstanding, please feel free to let me know.

I tried your code on my machine, it works fine. WebProxy.GetDefaultProxy()
can get the IE proxy setting properly.

However, according to the document, the GetDefaultProxy method reads the
nondynamic proxy settings stored by Internet Explorer 5.5 and creates a
WebProxy instance with those settings. The GetDefaultProxy does not pick up
any dynamic settings that are generated from script run by Internet
Explorer, from automatic configuration entries, or from DHCP or DNS lookups.

So could you please check the version of IE to see if it is higher than 5.5
and if the proxy setting is an automatic one?

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
J

Joshua Flanagan

I'm not positive, but the proxy settings may be stored for each user,
and not for the entire computer.

Try running your code in an interactive application (console or
winforms) and see if it picks up the proxy settings correctly.

It could be that when your application runs as a service, it runs under
a specific account which does not have the proxy settings configured or
loaded.
 
K

Kevin Yu [MSFT]

Thanks for Joshua's response.

Hi Robb,

I'm sorry that I didn't read your post clearly, since you're developing a
windows service. The proxy setting is user specific just as Joshua
mentioned. In a local system account, we cannot get the proxy setting for a
certain user.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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

Top