问题描述
您可能会说这是重复的,但是到目前为止我还没有找到任何有用的答案。
我只想测试加载文档。这是代码。很简单:
using System;
using System.Windows.Forms;
namespace ConsoleApp1 {
public class Program {
static bool completed = false;
[STAThread]
static void Main(string[] args) {
Webbrowser browser = new Webbrowser();
browser.Navigating += browser_Navigating;
browser.Navigated += browser_Navigated;
browser.DocumentCompleted += browser_DocumentCompleted;
browser.AllowNavigation = true;
browser.ScriptErroRSSuppressed = true;
browser.Url = new Uri("https://www.google.de/");
while (!completed)
continue;
Console.ReadKey();
}
private static void browser_Navigated(object sender,WebbrowserNavigatedEventArgs e) {
Console.WriteLine("Navigated" + System.Environment.NewLine);
}
private static void browser_Navigating(object sender,WebbrowserNavigatingEventArgs e) {
Console.WriteLine("Navigating..." + System.Environment.NewLine);
}
private static void browser_DocumentCompleted(object sender,WebbrowserDocumentCompletedEventArgs e) {
Console.WriteLine((sender as Webbrowser).Document.Title);
completed = true;
}
}
}
问题在于,此后仅Navigating...
输出到控制台。导航或DocumentCompleted在超过10分钟内都不会被调用。我错过了什么吗?关于msdn的一个答复说,我应该将Silent
设置为true
,但似乎已删除此属性。
设置Url
或Navigate
-方法均无效。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)