问题
Is it possible to change the HTTP status code returned by WCF Data Services when one of the query interceptors return false?
As a bonus, is there a way to selectively return different status codes depending on the query interceptor that failed?
回答1:
Could you use something like the following to access the current service method and change the returned HTTP method header information
WebOperationContext operationContext = new WebOperationContext(OperationContext.Current);
operationContext.OutgoingResponse.StatusCode = HttpStatusCode.Unauthorized;
回答2:
Turns out I was really looking for the Processing Pipeline.
For reference, an identical question can be found here. The same concerns and solution are also expressed here and there, respectively.
来源:https://stackoverflow.com/questions/18125558/query-interceptors-change-response-status-code