c# - How to access the Request object in a custom exception handler in ServiceStack -
i want register custom exception handler in servicestack. wiki @ https://github.com/servicestack/servicestack/wiki/error-handling says:
this.serviceexceptionhandler = (request, exception) => { //log exceptions here ... //call default exception handler or prepare own custom response return dtoutils.handleexception(this, request, exception); }; but in exception handler request argument not request object, rather service threw exception (at least can tell debugger). casting request ihttprequest fails invalidcast exception. since request/response members of service protected, cannot access request within exception handler.
what access request? in particular, need access content-type , list of accepted languages send headers in request.
from looking @ source, looks request should request dto, if need more that, can create own servicerunner<t>, , irequestcontext well, has contenttype property.
edit, bit more info:
when overwrite handleexception, can return httperror, allow set things headers , responsestatus etc.
Comments
Post a Comment