Share via

Maui Android web handler

Jerry Bonetti 5 Reputation points
2026-02-17T13:17:47.8833333+00:00

I am trying to create a webview handler for android in order to test calling a local web server with a self signed cert. I have seen numerous examples of how to create a client for WebView to capture the OnReceivedSslError methods but it is never called.

I am using Visual Studio 2026 with net 10.

I create the handler the client and the add handler logic in the startup.

Handler is initialized but OnReceivedSslError is never called when I create a WebView instance.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments
{count} votes

Answer recommended by moderator
  1. Jack Dang (WICLOUD CORPORATION) 14,955 Reputation points Microsoft External Staff Moderator
    2026-02-18T03:14:34.8033333+00:00

    Hi @Jerry Bonetti ,

    Thanks for reaching out.

    I took a closer look at what you described. If your custom handler is initializing but OnReceivedSslError is never being called, that usually means one of two things: either Android isn’t actually seeing an SSL error, or your custom WebViewClient isn’t the one being used by the WebView.

    The first thing I’d verify is whether the certificate is truly untrusted on the device/emulator. If the self-signed certificate has been installed or trusted through the Android network security configuration, the WebView won’t treat it as an error, and if there’s no SSL error, OnReceivedSslError will never fire. A quick way to confirm this is to browse to the same URL in Chrome on the device and see whether it shows a certificate warning.

    If you do see a warning in Chrome but still don’t hit OnReceivedSslError in your app, the next likely cause is that your custom WebViewClient isn’t actually attached to the native Android WebView. In .NET MAUI (especially with .NET 10), it’s important to explicitly set the client inside the handler’s ConnectHandler method, for example:

    • Override ConnectHandler(Android.Webkit.WebView platformView)
    • Call platformView.SetWebViewClient(new YourCustomClient())

    Even if the handler itself is registered in MauiProgram, MAUI can still assign its own default client unless you explicitly replace it at the platform view level. That’s often the missing piece.

    Also make sure you’re testing with an https:// endpoint and not http://localhost. If SSL isn’t actually being negotiated, there’s nothing for Android to validate.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.