Template Pages Error Handler

I am looking to create a gerneric catch all error page with TemplatePagesFeature in an aspnetcore kestrel app.

Is there a recommend way to handle error redirects with Templates for 404/500 status codes?

I’ve included page path constructors in this commit which lets you specify the path to the page (i.e. instead of a direct reference to the page) so you can register TemplatePageHandler the same as you would RazorHandler, e.g:

In this case if a Service threw a 404 HTTP Error Response it will return the /wwwroot/notfound.cshtml page whilst all other errors will return the /wwwroot/error.html page.

This change is available from v5.4.1 that’s now available on MyGet.

1 Like

Thanks Demis, looks ideal :thumbsup: