8

I want to get the current address and basically put it in a textbox. I found this link but can't seem to understand anything.

http://cefsharp.github.io/api/57.0.0/html/P_CefSharp_WinForms_ChromiumWebBrowser_Address.htm

I would really appreciate a code snippet from someone. It's killing me. i'm using WFA.

CsgoTalks Com
  • 151
  • 1
  • 1
  • 10
  • Please share your efforts so far, some code for example. – Chrille Jun 26 '17 at 12:49
  • I have the browser that's working fine https://puu.sh/wuFOg/3ac3a28bda.png Thing is, I want to verify if the link is redirected to one place or another = if the user is logger in or not. (it's a bit weird :) ) – CsgoTalks Com Jun 26 '17 at 12:51

3 Answers3

7

You have to listen to below address change event and persists it yourself.

this.Browser = new ChromiumWebBrowser();
this.Browser.AddressChanged += Browser_AddressChanged;

private void Browser_AddressChanged(object sender, AddressChangedEventArgs e)
        {
            this.CurrentAddress = e.Address;
        }
Pravin
  • 810
  • 1
  • 10
  • 17
  • 1
    There doesn't appear to be an "AddressChanged" event in the latest version for me..? – Zack Jun 09 '18 at 02:44
2

The browser object exposes the address using the property Address:

var browser = new ChromiumWebBrowser(...);
var currentAddress = browser.Address;
Chrille
  • 1,435
  • 12
  • 26
  • 2
    I did not found the browser.Address property on version 57, is it on older versions. – Pravin Oct 24 '17 at 19:04
  • @Pravin: It should still be avaliable in version 57: http://cefsharp.github.io/api/57.0.0/html/P_CefSharp_Wpf_ChromiumWebBrowser_Address.htm – Chrille Oct 25 '17 at 19:28
  • @Chrille There is no property called Address in version 67, how to get the DocumentComplete like webbrowser. – jkyadav Oct 17 '18 at 11:33
2

I'm using version 71 and the method:

TextBox1.Text = browser.Address;

Seems to work. Try updating to 71 and see if that helps, if you still have a problem with this.

"browser" is obviously the CefSharp browser control I've added programmatically. If you don't know how to do this, it's merely the following:

CefSharp.WinForms.ChromiumWebBrowser browser = new CefSharp.WinForms.ChromiumWebBrowser("https://google.com/");
w60
  • 49
  • 7
  • I don't see it in the Intellisense dropdown, but the property is there. Must have the `Browsable(False)` property attribute. – CrazyIvan1974 Jun 13 '19 at 22:00