var response = new HttpResponseMessage(HttpStatusCode.BadRequest)
{
Content = new StringContent("Error in Validation"),
ReasonPhrase = "Error in Validation"
};
throw new HttpResponseException(response);
The above code is not returning "Error in Validation" as response Content instead returns "Bad Request".
string result = response.Content.ReadAsStringAsync().Result;
I can read it from the ReasonPhrase but some customers want the error message in the response body. If HTTP Status is set as OK then it will return the correct message.