v5.4.1 breaking change for request params in template pages

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 populates slug with A
  • /posts/_slug/edit.html called from /posts/A/edit still populates slug with A

This topic is now pinned globally. It will appear at the top of its category and all topic lists until it is unpinned by staff for everyone, or by individual users for themselves.

This topic is now unpinned. It will no longer appear at the top of its category.