GetExceptionURL() with parameters

GetExceptionURL() with parameters

  

Hi there,
I have a page with parameters (blabla.aspx?param1=value1). I am calling GetExceptionURL() when I get a SecurityException to redirect the user back to the original url after login. But unless the error occurs in the preparation of a page, the GetExceptionURL() returns the URL without the query string parameters (and the user is redirected to blabla.aspx, with param1 empty). I believe this happens because the target of the Submit (or Ajax Submit) is the page, but does not have any parameters in itself. Anyway, is there a way to know the original parameters even in these cases?

Thanks!

Best Regards,
Pedro Vieira
Not sure,

But will you not stay in a loop?

page pops error -> error page -> click on link -> page pops eror -> error page -> ...


No, because this happens on a security exception, when the user is not logged in. Actually this is the normal behaviour of Outsystems on logging users: if the user is not logged in, while entering a webpage or somewhere in the middle of usage (like when clicking a button) it redirected to the login page and after login redirects again to the original page.

But if it happens while entering a page, the redirect keeps the original parameters, while if it happens on button click, the original parameters are lost.

Hi all, 

i have exactly this scenario, i want to redirect the user to the same page when a session timeout occurred or to a specific page while accessing using a direct link after being redirected to login screen.

Indeed as Pedro said, the querystring parameters are only lost when it happens on button click. Is there any workarround for this? Any other way to get GetExceptionURL() always with parameteres?


Thanks

Hi,


This is an old thread, but since there is still no answer here I'll share what we did just the other day, when asked the same question.


I'm not aware of a way to get the full URL from GetExceptionURL(), when a Security Exception is thrown because a user interacts with a screen after its session has expired.

But the following pattern can be used to get the full URL where the exception occurred, to be used to redirect the user back after a new Login:

  • On the preparation of the NoPermission screen, the one where you go when a SecurityException is caught, retrieve the Referer header from the HTTP Request (using the GetRequestHeader action from the HTTPRequestHandler extension);
  • Then check if the return from GetExceptionURL() is a substring of the value of the Referer Header:
    • If it is, then either they are the same or the Referer will contain the full URL (with query parameters) and you can use that as the target that the Login screen will use to redirect the user after successful login;
    • If not, then continue with the typical flow;



The animation below shows the pattern at work on the sample espace that's attached:


I hope this will be helpful to someone.

Thanks! I will check it out.

In the meantime we didn't solve the problem, and just redirect to a Home Page in this situation. The flow is as follows

1. HomePage

2. Page1?context=xxx. Parameter context is filled, so it's ok.

3. (session expires)

4. User clicks button -> Security Exception -> Login and redirect to Page1

5. Page1 doesn't receive context parameter -> Redirect to HomePage

I think this sample eSpace replicates that scenario, so I expect you to be able to use this pattern to do what you wanted and redirect the user back to screen with the full parameters context.

Let me know if it worked for you.