Skip to content

WebView in .NET MAUI fails to load URL with "&" character on Android despite URL encoding #26843

@alpayclsr1

Description

@alpayclsr1

The WebView control on Android is not loading certain URLs correctly. It has been determined that the issue arises when the URL contains the & symbol. This causes the URL to be prefixed with file:///android_asset/, preventing the page from loading.

Issue
Android: URLs containing the & symbol fail to load in the WebView. The WebView prepends the URL with file:///android_asset/, causing the navigation to fail.
iOS: The same URLs, when properly encoded, work correctly on iOS without any issues.
Web Browsers: These URLs open correctly in any web browser.

Steps to Reproduce
Create a new .NET MAUI application with a WebView.
Set the Source property of the WebView to a URL containing the & symbol (e.g., https://example.com/path?param1=value1&param2=value2) and ensure it is properly encoded.
Run the application on an Android device or emulator.
Expected Behavior
The WebView should navigate to the URL without any prefix, and the encoded URL should load correctly.

Actual Behavior
When the URL contains the & symbol, the WebView on Android prepends file:///android_asset/ to the URL, causing the page to fail to load.

Environment
.NET MAUI version: 8.0.93

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.93 SR9.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions