How to open a link in a native browser from CefSharp 3

Ahamed Salik picture Ahamed Salik · Jul 6, 2015 · Viewed 11k times · Source

I have a requirement to open a link in a native browser from CefSharp 3. I need to run the whole application in CefSharp 3's chromium browser except a form. when I click the form's link button (Eg - Register button. It has a link to the registration form) I need to open this link in the native browser (Eg - Internet Explorer).

Can we achieve this in CefSharp?

I searched the google as well as stack overflow. But unable to find a solution.

Answer

Ahamed Salik picture Ahamed Salik · Jul 7, 2015

As suggested by holroy I have implemented the OnBeforeNavigation() method in the RequestHandler class in CefSharp.Example package.

This is the working code,

 bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl,
 IBrowser browser, IFrame frame, IRequest request, bool isRedirect)
         {
             // If the url is Google open Default browser
             if (request.Url.Equals("http://google.com/"))
             {
                 // Open Google in Default browser 
                 System.Diagnostics.Process.Start("http://google.com/");
                 return true;
             }else
             {
                 // Url except Google open in CefSharp's Chromium browser
                 return false;
             }
         }

I hope this will help to some one else in future.

Thanks,