Handling parameters

TODO

There are 4 ways parameters are send to the server:

  1. within the URL itself
  2. as URL parameter
  3. as HTML Form values
  4. via cookies

Reading parameters is only one call:

Context.Request.Params['ParamName']

Parameters are read in the following order:

  1. URL Mapped parameters
  2. Query String parameters
  3. FORM parameters(eg. HTML Form Submit)
  4. Cookie fields

URL mapped parameters

GET /blog/posts/danieleteti/2013/11

[MVCPath('/posts/($user)/($year)/($month)')]
[MVCHTTPMethod([httpGET])]
procedure GetArticles(CTX: TWebContext);
. . .
procedure GetArticles(CTX: TWebContext);
var
  year, month: Integer; 
  user: string;
begin
  user  := CTX.Request.Params['user'];
  year  := CTX.Request.Params['year'].ToInteger;
  month := CTX.Request.ParamsAsInteger['month'];
end

QueryString mapped parameters

GET /blog/posts/danieleteti?year=2013&month=11

[MVCPath('/posts/($user)')]
[MVCHTTPMethod([httpGET])]
procedureGetArticles(CTX: TWebContext);
. . .
procedure GetArticles(CTX: TWebContext);
var
  year, month: Integer; 
  user: string;
begin
  user  := CTX.Request.Params['user'];
  year  := CTX.Request.Params['year'].ToInteger;
  month := CTX.Request.ParamsAsInteger['month'];
end

results matching ""

    No results matching ""