List icon Contents

Posted on July 26, 2021

DotNetBrowser 2.7

New DotNetBrowser 2.7 brings an updated Chromium engine and the API with new functionality.

What’s new

Chromium 91

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.

Profiles

DotNetBrowser API has been extended with Chromium profiles. Now, the architecture has the following structure:

Architecture

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:

  • ZoomLevels
  • Plugins
  • Proxy
  • Network
  • SpellChecker
  • CookieStore
  • HttpCache
  • Downloads
  • Permissions

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);

Every 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();

and

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 IProfiles.Remove(IProfile).

The default profile cannot be deleted.

Checkout the complete example demonstrating how to work with Chromium profiles: C#, VB.NET

View page source

Now you can view source of the loaded web page or frame like in Google Chrome:

browser.MainFrame?.ViewSource();

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:

Page source

Dark mode

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;

Background color

Picture-in-Picture

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.

Fixed issues

  • 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.

Improvements

  • It is now possible to work with JavaScript promises via IJsPromise type.
  • IFrame.Text property 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.
  • The SetWindowDisplayAffinity() WinAPI function used with WDA_MONITOR parameter no longer causes a Chromium crash when navigating to a different domain.

Request evaluation license
Download DotNetBrowser 2.7 (.NET Framework)
Download DotNetBrowser 2.7 (.NET Core)

Go Top