Welcome Guest Search | Active Topics | Sign In | Register

Not possible to see redirect URL in URLChanged event with build 2017.2.43 Options
Yves ORY
Posted: Wednesday, August 30, 2017 12:26:41 PM
Rank: Newbie
Groups: Member

Joined: 3/23/2017
Posts: 1
Hi
I have a problem in my application with the last 2017.2.43 build that I don't see with the 2017.0.40 build.

My application is a custom browser designed to access a secured web site that needs local access to smartcards on the PC.

To realize the data reading on the smartcards, The application on the web server has been designed to be accessed via a standard browser and to launch the process of the smartcards reading by sending a redirect URL to a local specific independant server that implements the smartcard reading.

The goal of my application is to suppress the local server and to be used in place of the standard web browser.
So my application implements a WebView and has embedded smartcards reading methods that must be invoked on demand.
The constraint is that the web application must not be modified. In other words, my application must react to the web application as a standard browser and a local server.

So, I implement the following events in my code :

private string MyLocalServerUrlPrefix = "https://127.0.0.1:1943";

void WebView_BeforeNavigate(object sender, BeforeNavigateEventArgs e)
{
if (e.IsRedirect)
{
// the web server has sent a redirect toward the supposed local server
// so I have to stop that redirect
if (e.NewUrl.StartsWith(MyLocalServerUrlPrefix))
{
e.Cancel = true;
}
}

}

async void WebView_UrlChanged(object sender, EventArgs e)
{
// to see the url in a url text box
if (m_txtUrl != null && m_txtUrl.IsVisible)
m_txtUrl.Text = m_CurPage.WebView.Url;

if (m_CurPage.WebView.Url.StartsWith(MyLocalServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
{
// the url of the selected tab WebView is intended to the supposed local server
string rep = "";
rep = await SmartCardReading(m_CurPage.WebView.Url)); // the url has parameters that are used by the SmartCardReading method
// the string rep is the response that contains an html form addressed to the web server.
m_CurPage.WebView.LoadHtml(rep, String.Empty); // the form is directly sent to the web server (like if it was sent by the local server)
}
}

This code perfectly works with the 2017.0.40 build.
But with the 2017.2.43, the UrlChanged event is never fired with the local url in my WebView.

What differences between the 2 builds can explain that ?
Is there anything that I do wrong or a better way to capture that redirect url ?

Thank you in advance for your help.
eo_support
Posted: Wednesday, August 30, 2017 1:35:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
Hi,

This was an issue that has been fixed since build 2017.0.40. The issue is in early builds (including 2017.0.40), the UrlChanged event was incorrectly fired together with BeforeNavigate event. Consider the following sequence of events:

1. The WebView already has url1 loaded;
2. User clicks a link that points to url2;
3. BeforeNavigate event is fired;
4. Your code cancels the navigation. As a result, nothing happens inside the WebView and it still has url1 loaded;

In older builds, UrlChanged event would be fired in between 2 and 3. Obviously there is in fact no UrlChanged taking place in this sequence. As such in the new build this event is no longer fired for this case. If you must detect the "intended" Url change event, you can rely on BeforeNavigate event.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.