This is very odd. I’ve written a windows form tool in C# to return the default IE proxy. It works (See code snippets below). I’ve created a service to return the proxy using the same code, it works when I step into the debugger, BUT it doesn’t work when the service is running as binary code. This must be some sort of permissions or context thing that I cannot recreate. Further, if I call the tool from the windows service, it still doesn’t return the proxy information…. this seems isolated to the service somehow. I don’t see any permission errors in the events log, it’s as if a service has a totally different context than a regular windows form exe.
I’ve tride both:
WebRequest.GetSystemWebProxy()
and
Uri requestUri = new Uri(urlOfDomain);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
IWebProxy proxy = request.Proxy;
if (!proxy.IsBypassed(requestUri)){
Uri uri2 = proxy.GetProxy(request.RequestUri);
}
Thanks for any help!
This article is quite old, but still relevant for Windows Services, although it does not cover IE proxy settings. These settings depend on the user, so the answer to your question is related to the user context of the service. If the service runs as Local System, it will not have the same IE settings as your own user account.