Reputation: 312
How can I get the URL of currently opened page in webview?
Actually I want to create a login scenario. so that I can integrate my university site for real-time notifications of assignments and quiz's.
Thanks in advance
Upvotes: 1
Views: 5528
Reputation: 36
It should be noted that the WebView_LoadCompleted event has been deprecated & is/will be obsolete. It may not be available after Windows 8.1 so you should use the NavigationCompleted event instead.
private void myWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
string myUrl = sender.Source.ToString();
}
Upvotes: 2
Reputation: 4666
Another idea would be to use InvokeScript and get the info from the document using javascript. Something like:
var url = await myWebView.InvokeScriptAsync("eval", new String[] { "document.location.href;" });
Hope it helps someone.
Upvotes: 7
Reputation: 15296
There's no direct property. You have to use LoadCompleted
event.
private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.Uri.ToString());
}
Upvotes: 3