使用带有WebBrowser对象的代理 [英] Using a proxy with the WebBrowser Object
问题描述
我一直在尝试在ac#应用程序中创建一个代理Web浏览器到目前为止我只是通过更改系统注册表来使用代理来实现这一点,这不是我想要的方式,因为这种效果PC上的所有浏览器我希望它在应用程序中。我试过了,但它没有奏效:
I've been trying to make a proxy web browser in a c# application so far I have only managed to do this by changing the system registry to use a proxy, this is not the way I want to do it as that effects all browsers on the PC i want it to be within the application. I have tried this but it is failing to work:
string proxyip = "200.54.246.14";
int proxyport = 8080;
System.Net.WebRequest.DefaultWebProxy = new WebProxy(proxyip, proxyport);
webBrowser1.Navigate("http://www.whatismyipaddress.com/");
webBrowser1.Refresh();
这不能用于whatismyipaddress网站将返回我的实际IP,它在我使用这种方法时有效:
This does not work the whatismyipaddress website will return my actual ip, it works when i use this method:
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", proxyip + ":" + proxyport.toString());
这个方法改变了整个电脑的代理设置,这不是我想做的......
任何建议?
谢谢
This method changes the proxy settings for the whole pc which is not what I want to do...
Any Suggestions?
Thanks
推荐答案
不幸的是,没有直截了当的解决方案我见过的样本依赖于覆盖Navigate方法,该方法在您直接加载页面时有效,但在用户单击返回文档中的超链接时失败。幸运的是,此处 [ ^ ]。
Unfortunately, there isn't a straightforward solution. I've seen samples that rely on the overriding the Navigate method which works when you directly load the page, but fails when the user clicks a hyperlink in the returned document. Fortunately, there's a thorough working solution here[^].
这篇关于使用带有WebBrowser对象的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!