Search code examples
maui

Maui WebView shows ERR_FILE_NOT_FOUND for a URL webpage with special characters


I'm using a WebView like this

<WebView Source="{Binding Url}"/>
viewModel.Url = "https://google.com/[]"

and on android it shows an ERR_FILE_NOT_FOUND message


Solution

  • Xamarin supported square brackets in URLs, but Maui does not. Replace them with their percent encoding.

    viewModel.Url = "https://google.com/[]".Replace("[", "%5B").Replace("]", "%5D");
    

    the page will then correctly load (as google's 404 page :P). As far as I can tell square brackets aren't universally supported anyway