How to make custom WCF error handler return JSON response with non-OK http code?

前端 未结 8 1630
春和景丽
春和景丽 2020-12-04 12:36

I\'m implementing a RESTful web service using WCF and the WebHttpBinding. Currently I\'m working on the error handling logic, implementing a custom error handler (IErrorHand

8条回答
  •  隐瞒了意图╮
    2020-12-04 13:02

    What does the ErrorMessage class look like?

    Don't use the StatusMessage field for machine-readable data -- see http://tools.ietf.org/html/rfc2616#section-6.1.1 .

    Also, it may be okay that "the http body now has the text 'Failed to load source for: http://localhost:7000/bla..' instead of the actual JSON data.." -- a literal string is JSON data if I remember correctly.

提交回复
热议问题