Skip to main content
 首页 » 编程设计

c#之WebBrowser.url 在 winform 中有时不工作

2024年01月02日38dyllove98

我将 url 值设置为 WebBrowser事件上的对象。有时设置此值不会反射(reflect)在 webBrowser 中。

我使用的代码是

webBrowser.Url= new Uri("www.google.com") 

我也试过 webBrowser.Navigate() 但行为相同。任何想法为什么会发生以及如何克服这个问题?

请您参考如下方法:

虽然这是一个非常老的问题,但对于访问此问题的人,请检查 WebBrowser 实例上设置的 AllowNavigation 属性。

根据 MSDN 文档 -

This property does not prevent you from loading an initial page by setting the Url, DocumentText or DocumentStream property, but will prevent all subsequent navigation.

您可以找到更多详细信息 here .