Causing HTTP error status to be returned in WCF

后端 未结 3 641
一向
一向 2021-02-10 02:28

How can I get my WCF service to communicate errors in a RESTful manner? Specifically, if the caller passes invalid query string parameters to my method, I\'d like to have a 400

3条回答
  •  独厮守ぢ
    2021-02-10 02:50

    If you are using standard WCF then FaultException is the correct approach to this. If you do not wish to do that and you want to be RESTful then you should use the REST WCF approach (Here is a quick start template for 4.0 and for 3.5). This fully supports returning HTTP Status Codes to the client.

提交回复
热议问题