How to get new parameters when application is recalled (callback)

Answered
0
0

My case:

– My application is called (https://myaddress/?p1=2&p2=aaa

  1. I detect and use such parameters in Program.Main
  2. I need to call some external address (to get a JWT) with Application.Navigate(…); I transmit my address as callback url
  3. after that I am recall with something like https://myaddress/?code=somecode. I can see that url in browser address, but:
  • Program.Main is no longer called (same session…)
  • I have Page.Appear event called, but I have no way to read the new parameter (code=somecode)

Please help me to get the code transmitted on the callback

  • You must to post comments
Best Answer
0
0

Hi Adrian,

please use Application.Uri it should contain the full query string that you can then parse.

Best regards
Frank

  • Adrian Zagar
    Application.Uri, used in Application.ApplicationRefresh works perfectly. Thank you for helping!
  • You must to post comments
0
0

the event handlers are ok.

To reproduce the problem (because you cannot simulate the API I call): Try a new project with an empty form and add just add in Main

Application.ApplicationRefresh += Application_ApplicationRefresh

and

private static void Application_ApplicationRefresh(object sender, EventArgs e)
{
MessageBox.Show(“Application_ApplicationRefresh:\n” + Application.Url);
}

Next, with the application running, go to address bar in the browser and add to it /?code=13 to existing address and hit enter.

You will see that the event triggers, but in Application.Url there is no code=13.

  • You must to post comments
0
0

What is the problem that persists?

You can attach event handlers. I don’t know what overwriting an event means.

All the parameters are all available in Url, Uri, StartupUrl, StartupUri and QueryString. See api docs for Application properties.

If you still need more details attach a small runnable fully contained project that shows what you are trying to do.

  • You must to post comments
0
0

I tried with both events, just Application.ApplicationRefresh is called, but as I told you, the Application.Url does not contains the code. See attached printscreen.

The code is:

private static void Application_ApplicationRefresh(object sender, EventArgs e)
{
Log(“Application_ApplicationRefresh:” + Application.Url);
MessageBox.Show(“Application_ApplicationRefresh:\n” + Application.Url);
}

Attachment
  • You must to post comments
0
0

Hi Adrian,

I don’t think I fully understood what you want to achieve.
Do you want to persist the parameters p1 and p2 that you receive when your application is launched?
If yes, just store them into your session.

For ApplicationRefresh and ApplicationHashChanged, they are regular .NET events and you can subscribe to them
like you would for any other event.

Best regards
Frank

  • Adrian Zagar
    What I want to achive: 1. When the application is launched, there are no parameters. Is like https://myaddress 2. During the application usage, I need to call another url with Application.Navigate(…) with a specific request, including https://myaddress as callback url 3. After the external site has done its magic, it calls me with https://myaddress/?code=somevalue. What I need is to get “somevalue”. I can catch the call, but “code=somevalue” is not accesible. Regarding ApplicationRefresh and ApplicationHashChanged, please provide a line of code to subscibe to one of them, specifying where can I put that code.
  • Frank (ITG)
    Application.ApplicationRefresh += Application_ApplicationRefresh; in Program.Main
  • You must to post comments
0
0

Hi Frank, thank you for answering.

Now I detect that change in Page.Appear event, not very elegant, but it’s called. Problem is that Application.Url replace the part I need. Instead of “https://myaddress/?code=somecode” (that can be seen on browser address) I get https://myaddress/?_sc=something. I presume that Wisej replaces real parameters with that _sc, probably to retrieve my session. So, up until now, the single point where I can get the real parameters from calling http is on Program.Main.

So the problem persists.

As a bonus, please instruct me how to overwrite events ApplicationRefresh or ApplicationHashChanged.

  • You must to post comments
0
0

Hi Adrian,

you might want to check out the events ApplicationRefresh or ApplicationHashChanged and query the Application.Url property.

Best regards
Frank

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.