Examples of using DotNetBrowser.
DotNetBrowser is a .NET library which allows embedding a Chromium-based browser into .NET applications to load and display web pages built with HTML5, CSS3, JavaScript, etc. It provides UI controls for WPF, WinForms, WinUI 3, and Avalonia UI that you can embed into your desktop application, and an off-screen rendering mode for console, headless, and server-side scenarios. It runs on Windows, macOS, and Linux.
To learn more about the library please visit the product page or the help center.
- .NET 5 - 10, or .NET Framework 4.6.2 - 4.8.1 (Windows only)
- Windows, macOS, or Linux, on x64 or ARM64 (x86 is also supported on Windows)
- A DotNetBrowser license key. Get the evaluation key
See the system requirements for the full list of supported operating systems and .NET versions.
-
Open the
dotnetbrowser.licensefile in the root directory with any text editor, copy and paste your license key and save the changes. The file is copied to the output directory of every example bycsharp/Directory.Build.propsandvbnet/Directory.Build.props.A few examples set the key in code through
EngineOptionsinstead and describe it in their own README: Docker, Local AI, Excel add-in, and Unity3D. -
Each folder under
csharp/andvbnet/has its own solution, such ascsharp/console/Console.sln,csharp/wpf/Wpf.sln, orcsharp/avalonia/Avalonia.sln. Open the one you need in Visual Studio 2022 or JetBrains Rider. -
Most examples are SDK-style projects targeting .NET 6 or later, so you can also run them from the command line without an IDE:
dotnet run --project csharp/console/GetHtml
The console, Avalonia, Docker, and web UI examples build on macOS and Linux with the .NET SDK alone.
-
The WinForms, WPF, VSTO, and ActiveX examples are .NET Framework 4.6.2 projects that use
packages.config. They need Visual Studio on Windows and an explicit restore: right-click the solution in "Solution Explorer" and select "Restore NuGet Packages", or runnuget restore <solution>.sln.
To build every solution for one language in a single pass, use the build.cake script in the root directory with --lang=csharp or --lang=vbnet. It requires Cake and MSBuild.
- Create two separate Chromium engines: C#, VB.NET
- Create two separate Chromium engines in different AppDomains: C#, VB.NET
- Create separate Chromium profiles: C#, VB.NET
- Load URL and listen to the navigation events: C#, VB.NET
- Embed into Windows Forms application: C#, VB.NET
- Embed into WPF application: C#, VB.NET
- Get page HTML: C#, VB.NET
- Walk through the hierarchy of frames on the web page: C#, VB.NET
- Get selected text on the web page: C#, VB.NET
- Find text on the web page: C#, VB.NET
- Text search (WinForms): C#, VB.NET
- Text search (WPF): C#, VB.NET
- Save web page: C#, VB.NET
- Save an image from the web page: C#, VB.NET
- Create web page screenshot: C#, VB.NET
- Create web page screenshot (cross-platform, uses SkiaSharp): C#, VB.NET
- Execute editor commands (Cut, Copy, Paste, Undo, Select All,
Insert Text etc.): C#, VB.NET - Access local storage of the web page: C#, VB.NET
- Update the zoom level on the web page: C#, VB.NET
- Print web page to PDF: C#, VB.NET
- Download a PDF file by its URL: C#, VB.NET
- Create new DOM element: C#, VB.NET
- Create and dispatch any DOM event (including custom events): C#, VB.NET
- Fill in and submit a form: C#, VB.NET
- Fill in and submit a multipage form: C#, VB.NET
- Work with attributes of the specific DOM element: C#, VB.NET
- Get DOM elements by tag name: C#, VB.NET
- Find element by CSS Selector: C#, VB.NET
- Intercept DOM Drag & Drop events: C#, VB.NET
- Get DOM node at a specific point on the web page: C#, VB.NET
- Get DOM node by mouse location (WinForms): C#, VB.NET
- Get DOM node by mouse location (WPF): C#, VB.NET
- Evaluate an XPath expression. Work with the evaluation result.: C#, VB.NET
- Work with Shadow DOM: C#, VB.NET
- Modify DOM element CSS style. Change DOM element visibility: C#, VB.NET
- Execute any JavaScript on the web page. Get JavaScript return value.: C#, VB.NET
- Read a value from the loaded web page with JavaScript: C#, VB.NET
- Work with JavaScript objects, update their properties and
invoke methods.: C#, VB.NET - Work with JavaScript arrays: C#, VB.NET
- Work with JavaScript name converting: C#, VB.NET
- Work with JavaScript Promises: C#, VB.NET
- Inject a .NET object into JavaScript. Get its properties and invoke
public methods from the JavaScript side.: C#, VB.NET - Execute JavaScript on UI event. Call back from JavaScript to
.NET UI (WinForms): C#, VB.NET - Inject object for scripting (
window.external): C#, VB.NET - Observe web page content changes on .NET side
usingMutationObserver: C#, VB.NET - Intercept Notification title and message: C#, VB.NET
- Redirect a URL request to another website. Access the URL
request headers.: C#, VB.NET - Intercept and handle URL requests: C#, VB.NET
- Handle
mailtoor any other URI scheme to open external application: C#, VB.NET - Access HTTP response data: C#, VB.NET
- Intercept the response data for AJAX requests: C#, VB.NET
- Suppress AJAX requests: C#, VB.NET
- Read and modify POST data : C#, VB.NET
- Intercept WebSocket data: C#, VB.NET
- Handle SSL certificate errors: C#, VB.NET
- Accept or reject SSL certificates: C#, VB.NET
- Filter out incoming and outgoing cookies: C#, VB.NET
- Get all stored cookies by URL: C#, VB.NET
- Share cookies between two IEngine instances with different user data directories (WinForms): C#, VB.NET
- Embed into Windows Forms ElementHost: C#, VB.NET
- Customize context menu in WPF: C#, VB.NET
- Customize context menu with WinForms: C#, VB.NET
- Customize context menu with Avalonia: C#
- Spell checker context menu in WPF: C#, VB.NET
- Spell checker context menu in WinForms: C#, VB.NET
- Spell checker context menu in Avalonia: C#
- Customize popup windows in WPF: C#, VB.NET
- Customize popup windows in WinForms: C#, VB.NET
- Customize popup windows in Avalonia: C#
- Configure custom keyboard shortcuts: C#, VB.NET
- Simulate keyboard input in WPF: C#, VB.NET
- Simulate keyboard input in WinForms: C#, VB.NET
- Simulate keyboard input in Avalonia: C#
- Work with Chromium DevTools: C#, VB.NET
- Install and manage Chrome extensions in WPF: C#
- Install and manage Chrome extensions in Avalonia: C#
- Handle Full Screen mode: C#, VB.NET
- Zoom web page on
Ctrl+Scroll: C#, VB.NET - WPF Demo application with tabs: C#
- Windows Forms Demo application with tabs: C#
- Work with the web page via UI Automation (MSAA/UIA): C#, VB.NET
- Display web page with transparent background in
a transparent WPF window: C#, VB.NET - Display web page with transparent background in
a transparent Avalonia window: C#, VB.NET - Intercept Drag & Drop events. Access
IDataObject: C#, VB.NET - Use DotNetBrowser with WPF data binding (MVVM): C#, VB.NET
- Use DotNetBrowser with Avalonia data binding (MVVM): C#
- Use Chromecast with DotNetBrowser in Avalonia: C#, VB.NET
- Use Chromecast with DotNetBrowser in WPF: C#, VB.NET
- Create a custom HTML UI: C#, VB.NET
- Create a custom web UI with TypeScript, React, and Shadcn UI: C#
- Build a Local AI Assistant application: C#
- WPF kiosk application: C#, VB.NET
- WinForms kiosk application: C#, VB.NET
- Avalonia kiosk application: C#
- Integrate with Google Maps: C#, VB.NET
- Integrate with Google Street View: C#, VB.NET
- Integrate with Selenium Chrome Driver: C#, VB.NET
- Integrate with Playwright: C#, VB.NET
- Integrate with Puppeteer: C#, VB.NET
- VSTO Add-In for Microsoft Outlook: C#, VB.NET
- COM Add-In for Excel: C#
- COM/ActiveX wrapper: C#, VB.NET
- Integrate with Unity3D: C#
- Integrate with Docker: C#
Feel free to submit request to our support team if you own a commercial license with an active support subscription. If you have any questions regarding using DotNetBrowser or the examples in this repository, contact us via email.
The information in this repository is provided on the following terms: https://www.teamdev.com/terms-and-privacy