You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CoreWebView2NavigationCompletedEventArgs does not include a Uri property. Why? #580
feature requestfeature requestpriority-lowWe have considered this issue and decided that we will not be able to address it in the near future.trackedWe are tracking this work internally.
The CoreWebView2NavigationCompletedEventArgs event does not include a Uri property. This is the event received when subscribing to the WebView2NavigationCompleted event. This is rather inconvenient and does not align with the CoreWebView2NavigationStartingEventArgs event which does include a Uri property.
Is this "by design"? Because it feels just like an omission.
Our we now supposed to use a dictionary of NavigationIds to figure out the Uri based on remembering the Uri we get in the NavigationStarting event?
private void WebBrowser_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e) { var uri = (sender as Microsoft.Web.WebView2.Wpf.WebView2).Source;
A fortiori, CEFSharp's frame navigation complete event gives the Uri of the frame. It's possible to get the Uri from WebView2's frame navigation started event, stash it in a Dictionary, then look it up on frame navigation completed. But it would have been super nice to not have to do that. Especially because it looks like the frame navigation completion event can fire while the debugger's stopped on a breakpoint in frame navigation started.
This one definitely needs to be in at least P2 if not P1. As more and more people migrate out of WebBrowser the need for URI in NavigationCompleted event will be felt.
santra-aMBODM (@mbodm) Could you please elaborate a bit more about the scenario you are trying to accomplish with URI property? Some example use cases would be very helpful. Thanks!
Nic Champagne Williamson [MSFT] (@champnic) I need this as well but also for iframes. And the [CoreWebView2Frame[(https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2frame?view=webview2-dotnet-1.0.2420.47) class doesn't contain any type of Source property, so I'm having to intercept the NavigationStarting event, grab the URI from that, save it in some datastructure mapped to my the navigation ID, and then retrieve it when NavigationCompleted has fired.
Nic Champagne Williamson [MSFT] (@champnic) I need this as well but also for iframes. And the [CoreWebView2Frame[(https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2frame?view=webview2-dotnet-1.0.2420.47) class doesn't contain any type of Source property, so I'm having to intercept the NavigationStarting event, grab the URI from that, save it in some datastructure mapped to my the navigation ID, and then retrieve it when NavigationCompleted has fired.
Yep, that‘s exactly the same, what i did. A developer’s only chance is to link the navigation IDs with the starting URLs. Since the IDs are your only single point of truth.
Would still keep this issue open, since it‘s wether a great solution (to a relatively simple problem, for the WebView2 devs, imo), nor do i like to bring such form of „state“ (i.e. some dict with IDs and URLs) into play.
Also this workaround becomes very „funny“ when dealing with redirects. 😜
feature requestfeature requestpriority-lowWe have considered this issue and decided that we will not be able to address it in the near future.trackedWe are tracking this work internally.
Activity
ukandrewc commentedon Oct 28, 2020
At that point, uri is available from
WebView2.urlorsender.urldmcgloin commentedon Oct 28, 2020
Thanks ukandrewc . But do you mean
source, as in:private void WebBrowser_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e) { var uri = (sender as Microsoft.Web.WebView2.Wpf.WebView2).Source;ukandrewc commentedon Oct 28, 2020
Sorry yes, Url is an extension of mine ;-)
dmcgloin commentedon Oct 28, 2020
Thanks ukandrewc
I guess I'm still calling this a bug/design issue.
champnic commentedon Nov 2, 2020
I've added this to our backlog, thanks!
OllieJones commentedon Aug 18, 2021
A fortiori, CEFSharp's frame navigation complete event gives the Uri of the frame. It's possible to get the Uri from WebView2's frame navigation started event, stash it in a Dictionary, then look it up on frame navigation completed. But it would have been super nice to not have to do that. Especially because it looks like the frame navigation completion event can fire while the debugger's stopped on a breakpoint in frame navigation started.
nonew commentedon Jul 5, 2022
Nic Champagne Williamson [MSFT] (@champnic)
When will this feature be added to the completed event args? It's been two years since the feature was proposed.
Thanks!
champnic commentedon Jul 5, 2022
This is currently a Priority 3 on our backlog, so I can't give an accurate timeline, but probably not for a while. Sorry.
santra-a commentedon Sep 1, 2022
This one definitely needs to be in at least P2 if not P1. As more and more people migrate out of WebBrowser the need for URI in NavigationCompleted event will be felt.
champnic commentedon Sep 7, 2022
santra-a I'll let the owning team know. Does the workaround of checking the "Source" property work for you in the meantime?
mbodm commentedon May 21, 2023
santra-a
Having an
e.Uriin theNavigationCompletedevent would be imo very appreciated.Foremost since your above workaround can not always be applied, cause of this WebView2 issue i had to handle with.
I had a hard time with all that stuff and my life would have been a million times easier if i had an
e.Uriin theNavigationCompletedevent. 😞novac42 commentedon Jun 13, 2023
santra-a MBODM (@mbodm) Could you please elaborate a bit more about the scenario you are trying to accomplish with URI property? Some example use cases would be very helpful. Thanks!
mbodm commentedon Jun 13, 2023
Hey santra-a,
thx for the reply.
In example here: #3461
Or in every other scenario, where you want to know the requesting Uri, when handling stuff in
NavigationCompletedevent.Best regards
Mogikan commentedon Dec 21, 2023
novac42 santra-a I'm using microsoft one drive sdk and trying to port it to winui 3.0 and webview2.0. As you can see there was an url property in args and it was used. And now it disappeared. How come that you deleted it? Why do you waste so many years in chats instead of simply fixing design bug?https://github.com/OneDrive/onedrive-sdk-dotnet-msa-auth-adapter/blob/master/src/OneDrive.Sdk.Authentication.UWP/Web/IotFriendlyWebDialog.xaml.cs
pushkin- commentedon May 28, 2024
Nic Champagne Williamson [MSFT] (@champnic) I need this as well but also for iframes. And the [CoreWebView2Frame[(https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2frame?view=webview2-dotnet-1.0.2420.47) class doesn't contain any type of
Sourceproperty, so I'm having to intercept the NavigationStarting event, grab the URI from that, save it in some datastructure mapped to my the navigation ID, and then retrieve it when NavigationCompleted has fired.mbodm commentedon May 29, 2024
Yep, that‘s exactly the same, what i did. A developer’s only chance is to link the navigation IDs with the starting URLs. Since the IDs are your only single point of truth.
Would still keep this issue open, since it‘s wether a great solution (to a relatively simple problem, for the WebView2 devs, imo), nor do i like to bring such form of „state“ (i.e. some dict with IDs and URLs) into play.
Also this workaround becomes very „funny“ when dealing with redirects. 😜