Provide WebView with Url to Asset

Viewed 172

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.

2 Answers

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

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%

Related