How can I use CefSharp to navigate to a specific URL?

4,605 views
Skip to first unread message

Gabriela Steren

unread,
Jan 26, 2015, 7:50:27 AM1/26/15
to cefs...@googlegroups.com
Hello.

I am new to CefSharp. I have downloaded it and I need to embed a browser in a window and feed it URLs to display.

I have done this with WebKit before, using the navigate method of the WebKitBrowser class. Is there any way to do the same with CefSharp? If so, what namespace, class and method do I need?

Thanks in advance.


NOTA CONFIDENCIAL DE INTERAXA S.A.:

Este mensaje (incluyendo cualquier anexo) contiene información confidencial y se encuentra protegido por la Ley. Sólo puede ser utilizada por la persona o compañía a la cual está dirigido. Si usted no es el receptor autorizado, o por error recibe este mensaje, favor borrarlo inmediatamente. Cualquier retención, difusión, distribución, copia o toma cualquier acción basada en ella, se encuentra estrictamente prohibido.

INTERAXA S.A. CONFIDENTIALITY NOTE:
This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is prohibited.

Gabriela Steren

unread,
Jan 26, 2015, 8:29:12 AM1/26/15
to cefs...@googlegroups.com
I have found the Load method in the WebView class, but I know I'm doing something wrong because I get a "Browser is not initialized" exception.

How can I initialize the browser? This is my code so far (the relevant parts):


            CefSharp.Settings settings = new CefSharp.Settings
            {
                PackLoadingDisabled = true,
            };
            if (CEF.Initialize(settings))
            {
                web_view = new WebView("about:blank", new CefSharp.BrowserSettings());
                web_view.Dock = DockStyle.Fill;
        
            }

...
            web_view.Load(url);

Where URL is a String which varies according to the application configuration. During my test it was http://www.missmab.com, but that is not really important.


Gabriela Steren

unread,
Jan 26, 2015, 12:32:36 PM1/26/15
to cefs...@googlegroups.com
Apparently it works if I catch the exception and run web_view.Address = url, although I don't know why.

If I use web_view.Address = url every time instead of web_view.Load(url), it only works the first time.


Jørn Hansen

unread,
Jan 26, 2015, 3:57:49 PM1/26/15
to cefs...@googlegroups.com
Hi, (and welcome to CefSharp :)

From the code you posted it looks like you are using a rather old version. In recent versions webView was replaced by ChromiumWebBrowser. See http://stackoverflow.com/questions/26307444/cefsharp-winforms-web-browser-wont-display for approximately bare minimum to get started with CefSharp.WinForms - from there take a look at CefSharp.MinimalExample and the FAQ linked to above here in the Google group. The ChromiumWebBrowser object is the main object.

Let's see how you go from there!

--
Best regards,
JornH

Gabriela Steren

unread,
Jan 27, 2015, 7:24:53 AM1/27/15
to cefs...@googlegroups.com
Thank you, Jørn, both for the welcome and for your reply. I will see if I can get a newer version to work.

--
You received this message because you are subscribed to a topic in the Google Groups "CefSharp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cefsharp/MLrrD4B90pw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages