For anyone using ServiceStack Templates, the latest v5.4.1 pre-release packages includes a breaking change where it will no longer auto import Request params (e.g. QueryString/FormData params) into scope arguments by default, instead it’s recommended for any user input to be accessed explicitly by using the new form
and query
filters:
{{ form.id }} or {{ form["id"] }} = Request.FormData["id"]
{{ qs.id }} or {{ query.id }} = Request.QueryString["id"];
Essentially anywhere you were accessing a Request param in your pages you should prefix it with the new accessor, e.g:
change {{ id }} to {{ qs.id }}
change {{ {id} }} to {{ {qs.id} }} or its equivalent {{ {id:qs.id} }}
If you want to keep using the same {{id}}
argument for request params you could explicitly assign it yourself:
{{ form.id ?? qs.id | assignTo: id }}
Or an easy way to import multiple params is with the new importRequestParams
filter at the top of your page:
{{ 'name,age,email' | importRequestParams }} or using a collection if preferred:
{{ ['name','age','email'] | importRequestParams }}
We recommend always being explicit with any user input, but you can also import all Request Params calling it with any arguments:
{{ importRequestParams }}
Finally you can quickly restore previous behavior and always import Request Params by setting:
Plugins.Add(new TemplatePagesFeature {
ImportRequestParams = true
});
However we’d recommend updating your pages to explicitly access any user input.
No impact on page based routing
Note: this doesn’t affect page based routing as the path info arguments you want to import are explicitly declared in the file or directory name, e.g:
-
/posts/_slug.html
called from/posts/A
still populatesslug
withA
-
/posts/_slug/edit.html
called from/posts/A/edit
still populatesslug
withA