Within a PreRequestFilter is it possible to find out the type of the current HTTP handler?
It hasn’t been determined at that point which is why the requestDto isn’t passed into the delegate, but you can use the same API we use to match the incoming route, e.g:
PreRequestFilters.Add((req, res) => {
string mimeType;
var match = RestHandler.FindMatchingRestPath(req.Verb,req.PathInfo,out mimeType);
var requestType = match.RequestType;
});
It’s the IServiceStackHandler
type I’m after rather than the requestType. For example is it RazorHandler
or RestHandler
, etc?
No it’s not possible, the handler is ultimately what’s executing the PreRequestFilter
but there’s no way to find out what unless you inspect the Environment.StackTrace
but it’s not something i’d be relying on in code also RazorHandler
is only used for Razor Content Pages any View Pages are executed in the context of a normal service request and Razor is used to render the result.