C
C#4mo ago
Padfoot

Changing Source on WebView MAUI results in using file scheme

Hello! I have a simple function which I'm using to change the source of my webview in MAUI. It works for my Android 11 phone but uses file scheme for a newer phone.
internal void RedirectWebView(string url)
{
try
{
wvMain.Source = new UrlWebViewSource
{
Url = url
};
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
internal void RedirectWebView(string url)
{
try
{
wvMain.Source = new UrlWebViewSource
{
Url = url
};
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
1 Reply
Padfoot
Padfoot3mo ago
I have run it locally and for both the phones it shows the string being sent as expected. After this executes, it tries to go to file:///android_asset/urlthatwassent which is not what I want it to do. Very interesting. We looked at the URL and it was happening because of the ascii encodings in the URL. We removed it by hardcoding the url and it started working. So stupid that it works on older Android phones and not on new ones.