A .NET MAUI class library providing an enhanced WebView control with JavaScript interop, navigation events, cookie management, and URL change detection for Android and iOS.
- Execute JavaScript from C# via
EvaluateJavaScriptAsync - Receive JavaScript calls in C# via
invokeCSharpAction(data)bridge - Navigation events:
Navigating,Navigated,WebViewNavigated - URL change detection for SPAs and PWAs via
UrlChanged(addresses dotnet/maui#19232) - Cookie management:
SetCookieAsync,UpdateCookieAsync,RemoveCookieAsync,RemoveAllCookiesAsync - Multi-window / popup support on Android
- Force reload via
Refresh()
| Platform | Minimum OS Version |
|---|---|
| Android | 21.0 |
| iOS | 12.2 |
Target Frameworks: net10.0-android, net10.0-ios (MAUI 10.0.41)
dotnet add package Com.Bnotech.ExtendedWebViewRegister the handler in your MauiProgram.cs:
using Com.Bnotech.ExtendedWebView;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseExtendedWebView(); // <-- Add this
return builder.Build();
}
}<!-- In your XAML page -->
<controls:ExtWebView x:Name="webView"
Source="https://example.com" />using Com.Bnotech.ExtendedWebView;Or set the source in code:
webView.Source = new UrlWebViewSource { Url = "https://example.com" };var request = new EvaluateJavaScriptAsyncRequest("document.title");
await webView.EvaluateJavaScriptAsync(request);The control automatically injects a invokeCSharpAction(data) function into every page. Subscribe to the event in C#:
webView.JavaScriptAction += (sender, e) =>
{
string payload = e.Payload;
// Handle the data sent from JavaScript
};Then call it from your web page:
invokeCSharpAction("Hello from JavaScript!");webView.Navigating += (sender, e) =>
{
// Fires before navigation starts
};
webView.Navigated += (sender, e) =>
{
// Fires after navigation completes
};Detects route changes in single-page applications that don't trigger traditional navigation events:
webView.UrlChanged += (sender, e) =>
{
string newUrl = e.Url;
};// Set a cookie
await webView.SetCookieAsync(
name: "session",
value: "abc123",
domain: ".example.com",
path: "/",
expires: DateTimeOffset.UtcNow.AddDays(7),
isSecure: true,
isHttpOnly: true);
// Update a cookie (overwrites by name/domain/path)
await webView.UpdateCookieAsync(
name: "session",
value: "newvalue",
domain: ".example.com",
path: "/");
// Remove a specific cookie
await webView.RemoveCookieAsync("session", ".example.com", "/");
// Remove all cookies
await webView.RemoveAllCookiesAsync();Force a reload of the current source:
webView.Refresh();| Property | Type | Description |
|---|---|---|
Source |
WebViewSource |
The URL or HTML content to display. Default: about:blank |
| Method | Description |
|---|---|
EvaluateJavaScriptAsync(request) |
Executes JavaScript in the WebView |
SetCookieAsync(...) |
Sets a cookie in the platform cookie store |
UpdateCookieAsync(...) |
Updates (overwrites) an existing cookie |
RemoveCookieAsync(name, domain, path) |
Removes a specific cookie |
RemoveAllCookiesAsync() |
Removes all cookies |
Refresh() |
Forces a reload of the current source |
| Event | EventArgs | Description |
|---|---|---|
JavaScriptAction |
JavaScriptActionEventArgs |
JS called invokeCSharpAction(data) |
Navigating |
WebNavigatingEventArgs |
Navigation is about to start |
Navigated |
WebNavigatedEventArgs |
Navigation completed |
UrlChanged |
UrlChangedEventArgs |
Displayed URL changed (SPA/PWA) |
SourceChanged |
SourceChangedEventArgs |
Source property was changed |
See LICENSE.