Razor exceptions hidden

We are using razor pages that are auto mapped as the html views for the DTO.

If there is an error with the razor page (which may occur because of unexpected data in the DTO), there is no error message, the html view switches from razor, to the standard:
“Snapshot of DTO generated by ServiceStack on TIME”

Note: the data displayed on the snapshot page at this time is blank or default values.

Is there any way to get the razor views to show errors instead of SS switching to the snapshot html view and hiding the exception?

You can try setting the IAppHost.GlobalHtmlErrorHttpHandler to specify a fallback HttpHandler, e.g:

public override void Configure(Container container)
    this.GlobalHtmlErrorHttpHandler = new RazorHandler("/oops"),

Just tried adding that line and some other code, but it’s not changing anything.

Do I need to do anything additional to that one line change? e.g. Do I have to create a new request DTO with a route for /oops?


Note: I also added in these delegates but it looks like they don’t apply (breakpoint not hit) to the way these errors are being propagated.

        this.ServiceExceptionHandlers.Add((httpReq, request, exception) =>
            //log your exceptions here
            //call default exception handler or prepare your own custom response
            return DtoUtils.CreateErrorResponse(request, exception);

        //Handle Unhandled Exceptions occurring outside of Services
        //E.g. Exceptions during Request binding or in filters:
        this.UncaughtExceptionHandlers.Add((req, res, operationName, ex) =>
            res.Write("Error: {0}: {1}".Fmt(ex.GetType().Name, ex.Message));
            res.EndRequest(skipHeaders: true);

Scratch that last post, ServiceExceptionHandlers caught the error, I needed to restart IIS for it to load updated DLLs.