I’m using #script in a multi tenant website. There’s a default _layout page, but for a specific tenant I want to create a custom layout page. So it should use the custom layout file if availabe else use the default.
Any best practice tips how to configure this scenario?
One more additional question around using the correct _layout file. Next to a tenant specific version there could also be a desktop/mobile/tablet specific layout page.
There’s no special support for tenants, but you can dynamically change which layout to render by returning a custom PageResult with the layout you want, e.g:
public class CustomerServices : Service
{
public object Any(ViewCustomer request) =>
new PageResult(Request.GetPage("examples/customer")) {
Layout = "...",
Model = TemplateQueryData.GetCustomer(request.Id)
};
}
You can also change which Layout to use by setting the “Template” IRequest.Items which you can do in a Request Filter, e.g: