-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Description
CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
Does not work with Ajax call.
CoreWebView2_WebResourceRequested Receives request but, it did not send back to the ajax caller.
Is it possible that CoreWebView2_WebResourceRequested acts as a webserver?
private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
{
if (e.Request.Uri.Trim().ToLower().StartsWith("http://history.codex.application/deletehistoryitem") == true)
{
// Do Somting
e.Response = environment.CreateWebResourceResponse(null, 200, "", "");
}
}
HTML
$.ajax({
url : `http://history.codex.application/deletehistoryitem?event_id=${event_id}`,
type : 'GET',
dataType:'json',
success : function(data, status, xhr) {
alert(data);
alert(status);
alert(xhr);
if (xhr == 200)
{
}
},
error : function(request,error) {
alert("Cant Delete History: ");
}
});
....
public async Task InitializeAsync()
{
await webView21.EnsureCoreWebView2Async(null);
webView21.CoreWebView2.Settings.AreDevToolsEnabled = true;// false;
webView21.CoreWebView2.Settings.IsScriptEnabled = true;
//webView21.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
webView21.CoreWebView2.Settings.IsStatusBarEnabled = false;
webView21.CoreWebView2.Settings.IsBuiltInErrorPageEnabled = false;
webView21.CoreWebView2.Settings.IsWebMessageEnabled = true;
webView21.CoreWebView2.Settings.AreDefaultContextMenusEnabled = true;// false;
webView21.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
environment = await CoreWebView2Environment.CreateAsync();
}
private async void CoreWebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
await webView21.CoreWebView2.ExecuteScriptAsync(_codexApps.GetInitialScript());
if (_codexApps.IsResponsive() == true)
{
webView21.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
webView21.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
}
}