Is there a way to prevent or override the initial redirection to the default page and directly navigate to the destination URL
I have a web application integrated into a WPF application using WebView2. My web application consists of two pages: the first page is the landing or default page located at "localhost/ABC/Search," and the second page is "localhost/ABC/Add."
In my WPF application, when a specific event occurs, I'm performing the following actions:
UTF8Encoding utfEncoding = new UTF8Encoding();
byte[] postData = utfEncoding.GetBytes(jsonContent);
MemoryStream postDataStream = new MemoryStream(postData.Length);
postDataStream.Write(postData, 0, postData.Length);
postDataStream.Seek(0, SeekOrigin.Begin);
CoreWebView2WebResourceRequest webResourceRequest = WebView2Environment.CreateWebResourceRequest(
"localhost/ABC/Add",
"POST",
postDataStream,
"Content-Type: application/json"
);
Webv.CoreWebView2.NavigateWithWebResourceRequest(webResourceRequest);
After executing this code, the application first redirects to the default page ("localhost/ABC/Search") for a few seconds before finally redirecting to the destination URL. Is there a way to prevent or override the initial redirection to the default page and directly navigate to the destination URL?
Let me know if you have any questions or need further clarification.
Hey @mukulnuance1234 - How are you setting the "default" page to "Search"? Are you navigating there manually or setting the Source property? If you are setting Source, you can probably remove that and use WebView2.EnsureCoreWebView2Async instead to initialize the control without navigating to "Search".