简体   繁体   中英

Using Proxy with web browser control

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

or there might be any solution ?

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 (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM