Query interceptors: Change response status code

岁酱吖の 提交于 2019-12-25 05:31:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!