Posted on July 26, 2021
New DotNetBrowser 2.7 brings an updated Chromium engine and the API with new functionality.
The Chromium engine has been updated to version 91.0.4472.114.
This Chromium version includes several important security fixes, so we recommend that you upgrade to this version.
Some of the Chromium features wrapped with the DotNetBrowser have been removed or changed. Check out the migration guide to see what DotNetBrowser API has been removed and what alternatives you should use instead.
DotNetBrowser API has been extended with Chromium profiles. Now, the architecture has the following structure:
Each Engine has a default
IProfile you can access via:
IProfile defaultProfile = engine.Profiles.Default;
The below services now belong to
IProfile. You can manage cookies, downloads, permissions, plugins, etc. independently for every profile:
To create a new regular or incognito profile use the following API:
IProfile profile = engine.Profiles.Create("MyProfile"); IProfile incognitoProfile = engine.Profiles.Create("MyIncognitoProfile", ProfileType.Incognito);
IBrowser instance has a profile. To create a
IBrowser instance for a specific profile, the following approach is used:
IProfile profile = engine.Profiles.Create("MyProfile"); IBrowser browser = profile.CreateBrowser();
For the backward-compatibility we didn’t change the
IEngine interface. It just delegates its calls to the default profile. For example:
IBrowser browser = engine.CreateBrowser(); // is equivalent of IBrowser browser = engine.Profiles.Default.CreateBrowser();
ICookieStore cookieStore = engine.CookieStore; // is equivalent of ICookieStore cookieStore = engine.Profiles.Default.CookieStore;
If you configure an
IEngine with the user data directory, then all created profiles will be restored after application restart unless you delete a profile via
The default profile cannot be deleted.
View page source
Now you can view source of the loaded web page or frame like in Google Chrome:
The code above tells Chromium to create and open a popup window with the HTML source of the main frame. It will be a regular popup with the following look:
It is also possible to force the preferred color scheme via Browser settings:
browser.Settings.PreferredColorScheme = PreferredColorScheme.Dark; //forces dark mode browser.Settings.PreferredColorScheme = PreferredColorScheme.Light; //forces light mode
The websites which respect the
prefers-color-scheme media query will switch to the light or dark mode accordingly.
Default background color
When Chromium does not know the background color of a web page, or the color has not been specified at all, it uses white color. In this version we extended the API with new functionality that allows you to configure the default background color that Chromium should use instead of the default white color in such cases.
The following code demonstrates how to set the desired background color for about:blank page:
Color purple = new Color(0.6f, 0.3f, 0.6f); browser.Settings.DefaultBackgroundColor = purple;
You can now watch videos in a floating window (on top of other windows) while interacting with other websites, or applications.
This functionality is only available in hardware-accelerated rendering mode.
- BrowserView getting blank while resizing the parent window to fullscreen in Off-screen rendering mode, while DotNetBrowser is embedded as a VSTO Add-In.
- The focus not restoring to the webpage after closing the PrintPreview dialog.
IFrame.Textproperty has been added. It allows getting content of a frame as plain text.
- The focus behavior for the WinForms BrowserView control in WPF applications has been improved.
SetWindowDisplayAffinity()WinAPI function used with
WDA_MONITORparameter no longer causes a Chromium crash when navigating to a different domain.
Subscribe to @DotNetBrowser on Twitter to get notified of the library updates.
Subscribe to our RSS feed to get instant updates on new releases.