Skip to content

Latest commit

 

History

504 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotNetBrowser-Examples

Examples of using DotNetBrowser.

Nuget Downloads Follow @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.

Requirements

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

How to run

  1. Open the dotnetbrowser.license file 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 by csharp/Directory.Build.props and vbnet/Directory.Build.props.

    A few examples set the key in code through EngineOptions instead and describe it in their own README: Docker, Local AI, Excel add-in, and Unity3D.

  2. Each folder under csharp/ and vbnet/ has its own solution, such as csharp/console/Console.sln, csharp/wpf/Wpf.sln, or csharp/avalonia/Avalonia.sln. Open the one you need in Visual Studio 2022 or JetBrains Rider.

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

  4. 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 run nuget 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.

List of examples

Basics

  • 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

Web page content

  • 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

DOM

  • 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

JS-.NET bridge

  • 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
    using MutationObserver: C#, VB.NET
  • Intercept Notification title and message: C#, VB.NET

Network

  • Redirect a URL request to another website. Access the URL
    request headers.: C#, VB.NET
  • Intercept and handle URL requests: C#, VB.NET
  • Handle mailto or 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

Media

  • List available audio and video devices. Select default media devices for
    the web page: C#, VB.NET

UI

  • 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

Specific use-cases

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

Examples for tutorials

  • How to deploy Chromium binaries over network: C#, VB.NET

Contact us

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

Used by

Contributors

Languages