![]() |
Redirect in form constructor - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Redirect in form constructor (/thread-2672.html) |
Redirect in form constructor - Adrien - 03-16-2022 Hi, Since I migrated to IW15, something I was doing previously does not work anymore. In the WebApp main form (which is a login page), I was reading parameters from the URL in order to bypass the login view if the correct "auth_token" is provided trough the URL parameters. This detection was done directly in the login form constructor : Code: constructor TLoginView.Create(AOwner: TComponent); This code does not work anymore in IW15. I tried using a timer and executing this code inside it, and it works. I suppose it is because the timer code is executed after the form is rendered and not in the form constructor. But is it the best way to handle a such redirection, or is there another recommended method ? Best regards, Adrien RE: Redirect in form constructor - Alexandre Machado - 03-17-2022 The recommended way is to use ServerController's OnGetMainForm event. From that event you can inspect the request and decide which form to create. Please note that you should create the instance of the form and pass it using the vMainForm parameter procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm); begin if SomeCondition then vMainForm := TMyMainForm.Create(WebApplication); end; RE: Redirect in form constructor - Adrien - 03-17-2022 Thank you very much for your answer. Will try ASAP ! Cheers from France, Adrien |