WCF 4.0 - Returning JSON WebFaultException with REST Service Template

后端 未结 3 852
名媛妹妹
名媛妹妹 2021-02-02 03:34

I am using the WCF REST Service Template 40(CS). I am throwing WebFaultExceptions as such:

throw new WebFaultException(\"Error Message\", HttpStatu         


        
3条回答
  •  春和景丽
    2021-02-02 04:18

    In you web.config set the value of AutomaticFormatSelectionEnabled to false

    
    

    Set the response format to json (which you have done already)

    [WebGet(UriTemplate = "", ResponseFormat = WebMessageFormat.Json)]
    

提交回复
热议问题