C# IE Proxy Detection not working from a Windows Service
- by mytwocents
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!