Atozed Forums
URL param with THandler - 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: URL param with THandler (/thread-1530.html)



URL param with THandler - etwoss - 02-09-2020

Hi

I use a Thandler like this:


Code:
  with THandlers.Add('/NewUser/', '', TContentForm.Create(TFrmNewUser)) do
  begin
     CanStartSession := True;
     RequiresSessionStart := True;
    end;

My url looks like:

Code:
http://127.0.0.1:8080/NewUser/$/?xxx=1

In the OnCreate of the TFrmNewUser form i coded:

Code:
  if (WebApplication.RunParams.IndexOfName('xxx') = -1) then
    param := 'no param'
  else
    param := WebApplication.RunParams.Values['xxx'];

But params stays empty.

What i'm missing?

Eric


RE: URL param with THandler - MrSpock - 02-09-2020

If I had a trouble like this, I would use the simplest code I could.
Code:
procedure TIWServerController.IWServerControllerBaseGetMainForm(
  var vMainForm: TIWBaseForm);
begin
  if WebApplication.RunParams.Count>0
  then
  begin
    if WebApplication.RunParams[0]='steg'
    then
      vmainForm:=TIWForm9.Create(WebApplication)
    else  
      vmainForm:=TIWForm2.Create(WebApplication) //main form
  end
  else
    vmainForm:=TIWForm2.Create(WebApplication) //main form
end;
What you need, as I see, is to choose the starting form depending also on the user, so you could just use another param to detect the user. Maybe there is another simpler way, but if something works for me, I use the code without looking for another solution.


RE: URL param with THandler - etwoss - 02-10-2020

Hi

WebApplication.RunParams.Count = 0 , thats the problem

Eric


RE: URL param with THandler - etwoss - 02-14-2020

The problem was that i tested the params in the OnCreate of the ContentForm, should be in the Execute method