C# 在执行时更改Gecko Webbrowser中的代理设置?
我想测试一个代理列表,每次加载X页,列表中的下一个代理 我正在使用Gecko webbrowser(GeckoFX),如何在执行webbrowser控件时更改代理IP:端口,以使用其他代理打开网页?试试看C# 在执行时更改Gecko Webbrowser中的代理设置?,c#,.net,vb.net,browser,gecko,C#,.net,Vb.net,Browser,Gecko,我想测试一个代理列表,每次加载X页,列表中的下一个代理 我正在使用Gecko webbrowser(GeckoFX),如何在执行webbrowser控件时更改代理IP:端口,以使用其他代理打开网页?试试看 GeckoPreferences.Default["network.proxy.type"] = 1; GeckoPreferences.Default["network.proxy.http"] = proxyAddress.Host; GeckoPreferences.Default["n
GeckoPreferences.Default["network.proxy.type"] = 1;
GeckoPreferences.Default["network.proxy.http"] = proxyAddress.Host;
GeckoPreferences.Default["network.proxy.http_port"] = proxyAddress.Port;
GeckoPreferences.Default["network.proxy.ssl"] = proxyAddress.Host;
GeckoPreferences.Default["network.proxy.ssl_port"] = proxyAddress.Port;
我通过以下方法完成了此操作:
''' <summary>
''' ProxyTypes of Gecko webbrowser.
''' </summary>
Public Enum ProxyType
''' <summary>
''' Direct connection, no proxy.
''' (Default in Windows and Mac previous to 1.9.2.4 /Firefox 3.6.4)
''' </summary>
DirectConnection = 0
''' <summary>
''' Manual proxy configuration.
''' </summary>
Manual = 1
''' <summary>
''' Proxy auto-configuration (PAC).
''' </summary>
AutoConfiguration = 2
''' <summary>
''' Auto-detect proxy settings.
''' </summary>
AutoDetect = 4
''' <summary>
''' Use system proxy settings.
''' (Default in Linux; default for all platforms, starting in 1.9.2.4 /Firefox 3.6.4)
''' </summary>
System = 5
End Enum
''' <summary>
''' Sets the proxy type of a Gecko Webbrowser.
''' </summary>
''' <param name="ProxyType">Indicates the type of proxy.</param>
Private Sub SetGeckoProxyType(ByVal ProxyType As ProxyType)
GeckoPreferences.Default("network.proxy.type") = ProxyType
End Sub
''' <summary>
''' Sets the proxy of a Gecko Webbrowser.
''' </summary>
''' <param name="Host">Indicates the proxy host.</param>
''' <param name="Port">Indicates the proxy port.</param>
Private Sub SetGeckoProxy(ByVal Host As String,
ByVal Port As Integer)
' Set the ProxyType to manual configuration.
GeckoPreferences.Default("network.proxy.type") = ProxyType.Manual
' Set the HTP proxy Host and Port.
GeckoPreferences.Default("network.proxy.http") = Host
GeckoPreferences.Default("network.proxy.http_port") = Port
' Set the SSL proxy Host and Port.
GeckoPreferences.Default("network.proxy.ssl") = Host
GeckoPreferences.Default("network.proxy.ssl_port") = Port
End Sub
“”
''代理型的壁虎网游者。
'''
公共枚举代理类型
'''
''直接连接,没有代理。
''(Windows和Mac 1.9.2.4/Firefox 3.6.4之前的默认设置)
'''
DirectConnection=0
'''
''手动代理配置。
'''
手动=1
'''
''代理自动配置(PAC)。
'''
自动配置=2
'''
''自动检测代理设置。
'''
自动检测=4
'''
''使用系统代理设置。
''(Linux中的默认值;从1.9.2.4/Firefox 3.6.4开始的所有平台的默认值)
'''
系统=5
结束枚举
'''
''设置Gecko Webbrowser的代理类型。
'''
''表示代理的类型。
私有子集geckoproxyType(ByVal ProxyType作为ProxyType)
GeckoPreferences.Default(“network.proxy.type”)=ProxyType
端接头
'''
''设置壁虎网络浏览器的代理。
'''
''表示代理主机。
''表示代理端口。
私有子SetGeckoProxy(ByVal主机作为字符串,
ByVal端口(作为整数)
'将ProxyType设置为手动配置。
GeckoPreferences.Default(“network.proxy.type”)=ProxyType.Manual
'设置HTP代理主机和端口。
GeckoPreferences.Default(“network.proxy.http”)=主机
GeckoPreferences.Default(“network.proxy.http_port”)=端口
'设置SSL代理主机和端口。
GeckoPreferences.Default(“network.proxy.ssl”)=主机
GeckoPreferences.Default(“network.proxy.ssl_port”)=端口
端接头
您好,很抱歉打扰您的话题。。。我测试了你的代码:但是当我按下按钮1时,什么都没有发生,表单不收费/@谢谢你。PS:当geck webbrowser上的代理连接失败时,您知道如何禁用代理警告消息框吗?@ElektroStudios,您可以将“browser.xul.error_pages.enabled”设置为“true”(显示没有消息框的错误页),或者您可以编写自己的PromptService来抑制消息。