Using Proxy with web browser control

我是研究僧i 提交于 2019-12-01 14:09:25

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.)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!