Federal09
Federal09

Reputation: 649

WebBrowser Url to string not work

When the code reaches MessageBox.Show() it throws an exception Object reference not set to an instance of an object.

Here is my code:

WebBrowser webb = new WebBrowser();    
webb.Navigate("https://www.facebook.com/logout.php?next=http://facebook.com&access_token=" + Settings.Default["token"].ToString());

MessageBox.Show(webb.Url.AbsoluteUri.ToString());

Do you see a reason why this might be the case ?

Upvotes: 0

Views: 223

Answers (1)

Federal09
Federal09

Reputation: 649

This might work:

WebBrowser webb = new WebBrowser();

private void pictureBox3_Click(object sender, EventArgs e)
{        
    webb.Url = new Uri("https://www.facebook.com/logout.php?next=http://facebook.com&access_token=" + Settings.Default["token"].ToString());
    webb.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted);        
}

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    MessageBox.Show(webb.Url.AbsoluteUri.ToString());
}

Upvotes: 1

Related Questions