We only just added initial support for using TemplatePages View Pages to render the HTML for Service Responses in this current release. It works similarly to Razor ViewPages where it uses first matching View Page where the Response DTO is injected as the Model property.
You can find tests on dynamically specifying the View and Template in TemplateViewPagesTests.
The View Pages can be in any folder in the /Views
folder with the format {PageName}.html
where PageName can be either the Request DTO Name, Response DTO Name or HttpResult.View
property if returning a custom HttpResult
. All page names need to be unique in the /Views
folder.
One difference from Razor is that it uses a cascading _layout.html
instead of /Views/Shared/_Layout.cshtml
. So if your view page was in:
/Views/dir/MyRequest.html
It will use the closest _layout.html
it can find starting from:
/Views/dir/_layout.html
/Views/_layout.html
/_layout.html
This is now available from ServiceStack v5 that’s now available on MyGet.