I want to login programmatically to another website by using webbrowser object so I have a webbrowser object in my project. The problem is Eachtime navigating it to any address, its "document" property remains null all the time and so the DocumentCompleted event never fires. The sample code is as below. Could you give any suggestions? Thanks in advance.
private WebBrowser browser;
protected void Page_Load(object sender, EventArgs e)
{
var t = new Thread(CreateBrowser);
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
private void CreateBrowser()
{
browser = new WebBrowser();
browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
browser.Navigate("http://www.google.com");
}