Skip to content
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

Is there a way to prevent or override the initial redirection to the default page and directly navigate to the destination URL #52

Open
mukulnuance1234 opened this issue Sep 15, 2023 · 1 comment

Comments

@mukulnuance1234
Copy link

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.

@champnic
Copy link
Member

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants