Enhanced .NET MAUI WebView control with advanced browser capabilities, real-time content monitoring, and PDF processing. Features include custom user-agent configuration, debounced DOM change detection, PDF handling, cookie management, and seamless cross-platform support for Android, iOS, and Windows. Key Features: - Custom User-Agent and browser detection bypass - Real-time content monitoring with intelligent debouncing (1-second delay) - Automatic PDF download handling and text extraction - Link extraction with Routes (all page links) and BodyRoutes (content-only links) - Full cookie and storage support - WebRTC and WebGL compatibility - Cross-platform implementation (Android, iOS, Windows) - Event-based content updates via PageDataChanged event - JavaScript injection support - Production-ready with optimized performance Perfect for applications requiring advanced web content interaction, monitoring, and processing.
$ dotnet add package MarketAlly.ViewEngineMarketAlly.Maui.ViewEngine is a powerful .NET MAUI WebView control that mimics a real browser, enabling full JavaScript support, cookies, WebRTC, and custom User-Agent overrides. It works seamlessly across Android, iOS, and Windows with advanced content monitoring and automatic PDF extraction capabilities.
✅ Supports custom User-Agent ✅ Enables cookies, storage, WebRTC, and WebGL ✅ Bypasses WebView detection techniques ✅ PageDataChanged event - Automatically triggered on navigation and dynamic content changes ✅ Intelligent content monitoring with debounced DOM change detection ✅ Automatic PDF extraction - Detects and extracts text from PDF URLs ✅ Cross-platform JavaScript injection for custom behaviors ✅ Fully compatible with .NET MAUI ✅ Works on Android, iOS, and Windows
To install the package, run the following command in your .NET MAUI app:
dotnet add package MarketAlly.Maui.ViewEngine
Or, in Visual Studio:
Install-Package MarketAlly.Maui.ViewEngine
MauiProgram.csAfter installing, you must register the custom WebView handler inside your .NET MAUI app.
MauiProgram.cs to add the handler:using MarketAlly.Maui.ViewEngine;
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>();
// Register the custom WebView handler
builder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler(typeof(MarketAlly.Maui.ViewEngine.WebView),
typeof(MarketAlly.Maui.ViewEngine.WebViewHandler));
});
return builder.Build();
✅ This ensures your app correctly loads the WebView with platform-specific optimizations.
WebViewOnce registered, you can use WebView in XAML or C#.
<ContentPage xmlns:viewengine="clr-namespace:MarketAlly.Maui.ViewEngine;assembly=MarketAlly.Maui.ViewEngine">
<viewengine:WebView
Source="https://example.com"
UserAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
PageDataChanged="WebView_PageDataChanged"/>
</ContentPage>
private void WebView_PageDataChanged(object sender, PageData pageData)
{
// Access extracted page data
string title = pageData.Title;
string bodyText = pageData.Body;
string url = pageData.Url;
string metaDescription = pageData.MetaDescription;
// Access all links found on the page (navigation, header, footer, etc.)
var allLinks = pageData.Routes;
foreach (var route in allLinks)
{
Console.WriteLine($"Link: {route.Text} -> {route.Url} (Absolute: {route.IsAbsolute})");
}
// Access links found specifically in the body content
var contentLinks = pageData.BodyRoutes;
foreach (var route in contentLinks)
{
Console.WriteLine($"Body Link: {route.Text} -> {route.Url}");
}
}
using MarketAlly.Maui.ViewEngine;
var webView = new WebView
{
Source = "https://example.com",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
};
webView.PageDataChanged += (sender, pageData) =>
{
// Handle page data extraction
Console.WriteLine($"Page Title: {pageData.Title}");
};
Content = new StackLayout
{
Children = { webView }
};
var pageData = await webView.GetPageDataAsync();
Console.WriteLine($"Title: {pageData.Title}");
Console.WriteLine($"Body: {pageData.Body}");
Console.WriteLine($"URL: {pageData.Url}");
The PageData object provides comprehensive information about the loaded page:
public class PageData
{
public string Title { get; set; } // Page title
public string Body { get; set; } // Extracted text content
public string Url { get; set; } // Current URL
public string MetaDescription { get; set; } // Meta description tag
public List<Route> Routes { get; set; } // All links on the page
public List<Route> BodyRoutes { get; set; } // Links within the body content
}
public class Route
{
public string Url { get; set; } // Link URL
public string Text { get; set; } // Link text
public bool IsAbsolute { get; set; } // Whether URL is absolute
}
The WebView extracts links from the page in two different collections:
Routes - All links found anywhere on the page:
BodyRoutes - Links found specifically within the main content area:
webView.PageDataChanged += (sender, pageData) =>
{
// Get all navigation and content links
Console.WriteLine($"Total links found: {pageData.Routes.Count}");
// Get only links within the main content
Console.WriteLine($"Content links: {pageData.BodyRoutes.Count}");
// Example: Find external links in the content
var externalContentLinks = pageData.BodyRoutes
.Where(r => r.IsAbsolute && !r.Url.Contains(pageData.Url))
.ToList();
// Example: Get navigation menu items (links not in body)
var navigationLinks = pageData.Routes
.Except(pageData.BodyRoutes)
.ToList();
};
The WebView automatically detects PDF URLs (by extension, content-type, or URL patterns) and extracts text content:
webView.PageDataChanged += (sender, pageData) =>
{
if (pageData.Title.Contains("PDF"))
{
// PDF was detected and extracted
Console.WriteLine($"PDF Pages: {pageData.MetaDescription}");
Console.WriteLine($"PDF Text: {pageData.Body}");
}
};
Supported PDF URL patterns:
.pdf file extensions/pdf/ in the pathcontent-type=pdf, type=pdf, format=pdfThe WebView includes intelligent DOM monitoring that detects:
Debouncing: Content change notifications are automatically debounced (1 second) to prevent excessive event firing from rapid DOM mutations.
// Inject custom JavaScript
await webView.Handler.InjectJavaScriptAsync("alert('Hello from MAUI!');");
Android.Webkit.WebViewWebViewClient for navigation interceptionWKWebView with full JavaScript supportWKNavigationDelegate for navigation handlingWebView2 (Chromium-based)MarketAlly.Maui.ViewEngine.WebView provides:
.NET MAUI WebView lacks these advanced features.The event fires automatically:
All events are debounced to prevent excessive firing.
Yes! Cookies and session data persist between navigations, making it suitable for login-based websites.
Yes! It uses:
WKWebView with full JavaScript and cookie supportWebView2 (Chromium-based)Yes! The WebView can be used for OAuth authentication flows, but we recommend opening authentication pages in the system browser (e.g., SFSafariViewController for iOS or Custom Tabs for Android) for better security.
Content monitoring is built-in and optimized with debouncing. If you only need navigation events, simply don't subscribe to content change notifications from the monitoring script.
The PDF extraction happens automatically. You can identify PDF content in the PageDataChanged event by checking if the title contains "PDF" or by examining the MetaDescription which includes page count information.
Want to improve this library? Feel free to submit issues and pull requests on https://github.com/MarketAlly/MarketAlly.ViewEngine
This project is licensed under the MIT License.
💬 Need help?
Open an issue on GitHub or contact us via email at support@marketally.com. 🚀