Using Proxy with web browser control

后端 未结 2 884
北恋
北恋 2021-01-17 06:47

is it possible to use two web browser controls with different proxies without writing the registry.

or there might be any solution ?

相关标签:
2条回答
  • 2021-01-17 07:26

    You cannot do this with the Web Browser Control. InternetSetOption allows you to set a proxy, but your choices are only "For all processes" or "For this process". You cannot set the proxy individually for a single control. If there's something distinct about the traffic (e.g. one control goes to 1 server, the other goes to another) you could configure the process to use a Proxy Configuration Script (search for FindProxyForURL) to chain traffic bound for different servers to different proxies.

    If you do set the proxy, you should use InternetSetOption rather than directly manipulating the registry.

    (As a workaround, you COULD put FiddlerCore into your process, set your process to use FiddlerCore, and then have FiddlerCore send traffic from each control to a different upstream gateway, but that requires that you find some way to distinguish traffic from each control.)

    0 讨论(0)
  • 2021-01-17 07:50

    Actually I think that writing the registry is the only way because WebBrowser creates an instance of Internet Explorer, so you have to change IE settings modifying the registry.

    If you don't want to change actual configuration you could store proxy address, modify it with yours and then restore it when the application closes.

    0 讨论(0)
提交回复
热议问题