Reputation: 16246
I am looking at AppHostBase.cs
and it has the following:
//....
public IContentTypeFilter ContentTypeFilters {
get {return EndpointHost.ContentTypeFilter;}
}
public List<Action<IHttpRequest, IHttpResponse>> PreRequestFilters {
get {return EndpointHost.RawRequestFilters;}
}
public List<Action<IHttpRequest, IHttpResponse, object>> RequestFilters {
get {return EndpointHost.RequestFilters;}
}
public List<Action<IHttpRequest, IHttpResponse, object>> ResponseFilters {
get {return EndpointHost.ResponseFilters;}
}
//....
I read from the SS website document and know what is RequestFilters
and ResponseFilters
. But why is there a PreRequestFilter
seperated from RequestFilters
? What is it for?
I google'd around and see an example of SignalR code written in PreRequestFilters
why not just write it in RequestFilters
what is the difference?
Upvotes: 4
Views: 1892
Reputation: 12015
According to the Order of Operations, Pre-Request Filters are executed before the DTO is deserialized, and regular RequestFilters are executed after that. Also note that request filters are executed in a specific order depending on whether they are implemented as Attributes or registered via AppHost, and also based on the Priority of the request filter attributes.
Upvotes: 5