'Provide WebView with Url to Asset

In my Uno UWP project, I can view an html Asset file (w/ Content BuildAction), stored in my shared project, using the following:

   var myAssetUri = new Uri("ms-appx-web:///Assets/Html/index.html");
   myWebView.Navigate(myAssetUri);

However, this does not work with Android or WASM (not yet tried on other platforms). On WASM, I get a blank page. On Android, I get a page with the message:

The webpage at ms-appx-web:///Assets/Html/index.html could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME

When I look at the package folders for both platforms, I do find my html file:

  • WASM: bin/Debug/netstardard2.0/dist/package_.../Assets/Html/index.html
  • Android: (unziping my app's apk) assets/Html/index.html

so, I am guessing I'm not doing something right ... but I don't know what that might be.



Solution 1:[1]

The cause is simple: WebView not implemented yet on Wasm nor Skia.

Solution 2:[2]

This is the solution after hours investing!!

For you proyect write this line:

var myAssetUri = new Uri("file:///android_asset/Assets/Assets/Html/index.html");

This work 100%

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Carl de Billy
Solution 2 Jose Miguel Garcia