导航到IPv6地址时,.NET WinForms WebBrowser控件会引发异常

时间:2014-01-17 14:17:40

标签: c# winforms browser ipv6

我有一个WinForms Web浏览器控件。当我使用IPv6地址调用Navigate()时,我得到一个ArgumentException,这不是一个记录的调用异常。 WebBrowser控件是否仅支持IPv6地址?

System.ArgumentException: Value does not fall within the expected range.
   at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.Navigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
   at System.Windows.Forms.WebBrowser.PerformNavigate2(Object& URL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
   at System.Windows.Forms.WebBrowser.PerformNavigateHelper(String urlString, Boolean newWindow, String targetFrameName, Byte[] postData, String headers)
   at System.Windows.Forms.WebBrowser.Navigate(String urlString)

1 个答案:

答案 0 :(得分:1)

您必须将ip v6地址括在方括号[]

参见此处的参考资料

http://www.cyberciti.biz/faq/how-can-ipv6-address-used-with-webbrowser/

希望这也适用于网络浏览器控件。