-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreWebView2_WebResourceRequested Not respons to ajax call. #1160
Comments
Hey @IrakliLomidze - yes, part of the intent with WebResourceRequested is to be able to short-circuit a network call and instead provide the response from the host app. At what point in your scenario is this not working? |
CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e) In Webview2 Devtools Ajax call, I have network status pending. But I think the response is sending somewhere else because on an HTML page (Dev Tools shows that my js code still awaiting response) ... ... e.Response = environment.CreateWebResourceResponse(null, 200, "", ""); Environment : Windows 10 / 20H1, .NET 4.8 WinForm / VS 2019 Latest Uptate / WebView Latest Neget Update |
I have found solution:
And most important that is not documented in WebView2 Documentation, When the page is loaded from the Local File system. Do not forget disable CORE Policy: And champnic Please made possible custom URLs. like myappname:\action\params ... |
Glad you've got it working @IrakliLomidze! We're are tracking custom urls in #173. |
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({
....
public async Task InitializeAsync()
{
await webView21.EnsureCoreWebView2Async(null);
private async void CoreWebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
await webView21.CoreWebView2.ExecuteScriptAsync(_codexApps.GetInitialScript());
The text was updated successfully, but these errors were encountered: