I have built a Multi Platform .NET8 MAUI application. Currently I am focusing on Windows 10.0.22621 and Android 14.
I have an HTML page (MauiAsset) loaded into the Source WebView.
In that HTML page there is some Javascript code similar to the tutorial at W3School: https://www.w3schools.com/js/js_cookies.asp
The problem is that I have run the application and successfully displayed the HTML page, but the Javascript scripts related to Cookies are all rejected.
I have searched a lot but most of the solutions are using C# code mechanism (Behind Page) or ViewModel MVVM to work with Cookies.
Or if you want to use Javascript, you have to use the mechanism of calling Javascript Function on C# Behind Code.
var passSomeValueCsharCodeBehind = "2024";
var resultValueFromJavascript =
await xNameWebViewControl.EvaluateJavaScriptAsync(
$"nameFunctionJavascript({passSomeValueCsharCodeBehind})"
);
//SetCookie(resultValueFromJavascript) from C# Behind
It’s a hassle if I have a lot of other Functions, Javascript variables related to Cookie. Because I and a lot of people have to refactor the whole code.
So does anyone know how to get permission to use Javascript set/get Cookie on MAUI WebView?