0

Following scenario:

  • Having a hosted IE web browser control and an in-app web server (like this one).
  • The web server runs at (e.g.) http://127.0.0.1:14284 and the web browser calls this URL.

Now we have a customer which has a proxy server configured in IE options, and also checked "bypass proxy on local addresses".

Unfortunately, the hosted IE web browser control still used the proxy settings, even for the local URL http://127.0.0.1:14284.

My question is:

Am I somehow able to tell my hosted web browser to always directly call my hosted web server, without going through a proxy?

(I found this thread but still am unsure how to apply this to my question)

Community
  • 1
  • 1
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

1 Answers1

2

I think you have to do some interop, as the docs say you can disable the proxy with the InternetSetOption function. There are a lot of flags you can pass to this function you need INTERNET_OPTION_PROXY or INTERNET_OPTION_PER_CONNECTION_OPTION, theres also a kb-article which describes how to set the proxy settings.

I hope I helped you a bit :)

MBulli
  • 1,659
  • 2
  • 24
  • 36
  • Thank you, @AntiLamer - Currently I am unable to draw a line between the `WebBrowser.Navigate` I am calling and the `InternetSetOption` method call. I do not see any relationship on this. – Uwe Keim Mar 16 '11 at 15:09
  • 1
    @Uwe Keim As your wrote your customer set "bypass proxy on local addresses" but the webbrowser still using the proxy, so I thought a way to workaround this issue, is to disable the proxy, of course only for your control/process. Because the .Net framework hasn't any class or methode for this you might use InternetSetOption function which affects all internet explorer instances, the webbrowser control included. But it's just plain theory I have not tested it. – MBulli Mar 16 '11 at 21:02
  • Thanks @AntiLamer - If I somehow manage to call the `InternetSetOption` for the local process (without admin permissions), the web browser control will automatically use these options? – Uwe Keim Mar 17 '11 at 05:43
  • Seems that [passing `IntPtr.Zero` for the `HINTERNET` handle](http://stackoverflow.com/questions/4251537/get-webbrowsercontrols-axiwebbrowser2-handle-for-use-in-internetsetoption-com-i/4251585#4251585) works for the whole process - this is what I want, actually. I'll think I'll give it a try. Hopefully no admin permission is required for this. – Uwe Keim Mar 17 '11 at 06:44