That seems to work but it seems like that the memory consumption increases a lot for each refresh/reload so bit worrying
This is not matter. If you open the Task Manager and refresh the brower you will find the browser's memory consumption also increases a lot.
But you can also try to reload the current url in the webview to check the memory consumption.In the MainPage.xaml:
<BlazorWebView x:Name="blazorWebView"/>
In the MainPage.cs:
public void Reload(string url) {#if Android var androidweb = blazorWebView.Handler.PlatformView as Android.Webkit.WebView; androidweb.LoadUrl(url);#elif WINDOWS var windowweb = blazorWebView.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2; windowweb.Source = new Uri(url);#elif IOS var iosweb = blazorWebView.Handler.PlatformView as WebKit.WKWebView; iosweb.LoadRequest(new Foundation.NSUrlRequest(new Uri(url)));#endif }
And in the razor page:
@inject NavigationManager nav;@code{ public void Refresh() { (App.Current.MainPage as MainPage).Reload(nav.Uri); }}