C# IE Proxy Detection not working from a Windows Service

Posted by mytwocents on Stack Overflow See other posts from Stack Overflow or by mytwocents
Published on 2010-04-12T22:31:40Z Indexed on 2010/04/12 22:32 UTC
Read the original article Hit count: 261

Filed under:

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!

© Stack Overflow or respective owner

Related posts about .NET