diff --git a/CefSharp.WinForms/ChromiumWebBrowser.cs b/CefSharp.WinForms/ChromiumWebBrowser.cs index 171bcd7ae..602e9effa 100644 --- a/CefSharp.WinForms/ChromiumWebBrowser.cs +++ b/CefSharp.WinForms/ChromiumWebBrowser.cs @@ -52,6 +52,12 @@ namespace CefSharp.WinForms /// private bool browserCreated; /// + /// A flag indicating if the was used when calling CreateBrowser + /// If false and contains a non empty string Load will be called + /// on the main frame + /// + private bool initialAddressLoaded; + /// /// Browser initialization settings /// private IBrowserSettings browserSettings; @@ -645,6 +651,8 @@ namespace CefSharp.WinForms { var windowInfo = CreateBrowserWindowInfo(Handle); + initialAddressLoaded = !string.IsNullOrEmpty(Address); + managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings as BrowserSettings, requestContext as RequestContext, Address); browserSettings = null; @@ -681,6 +689,13 @@ namespace CefSharp.WinForms ResizeBrowser(); + //If Load was called after the call to CreateBrowser we'll call Load + //on the MainFrame + if (!initialAddressLoaded && !string.IsNullOrEmpty(Address)) + { + browser.MainFrame.LoadUrl(Address); + } + IsBrowserInitializedChanged?.Invoke(this, EventArgs.Empty); }