Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF WebBrowser - detecting redirects?

Tags:

c#

facebook

wpf

I am trying to implement a simple Facebook login flow using WPF. It turns out that I need to use some sort of embedded browser within the application if the application is a desktop application. Therefore I am using WebBrowser control, but I can't seem to correctly detect the redirecting URL.

Once I load the web page for facebook login, and after login, the browser redirects to a page of the form

https://www.facebook.com/connect/login_success.html#access_token=....

But if I look at the URI source, it only shows up to login_success.html and is cutting off whatever is after the # sign. I need this information for further processing, so I was wondering if anyone could advise on retrieving that access token using WebBrowser (or any other way) in WPF. Thanks!

like image 505
the Avatar asked May 29 '26 13:05

the


1 Answers

I was having the saving problem with the WPF Sample in the SDK today. I figured it was a problem with the WPF Webbrowser control (like you had infered). So I used the windows.forms.webbrowser instead of the WPF webcontrol. It is a simple fix.

 System.Windows.Forms.Integration.WindowsFormsHost host =
        new System.Windows.Forms.Integration.WindowsFormsHost();
 _webBrowser = new System.Windows.Forms.WebBrowser();
 host.Child = _webBrowser;

 this.grid1.Children.Add(host);
 _webBrowser.Navigated += new WebBrowserNavigatedEventHandler(webBrowser_Navigated);
 _webBrowser.Navigate(_navigateUrl.AbsoluteUri);
like image 162
Augustine Mathew Avatar answered Jun 01 '26 01:06

Augustine Mathew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!