I've seen many examples about use of HttpResponseException type in order to return a differents http status code through the raising of this exception.
However, all times I try to raise a HttpResponseException, client side I always receive 500 Internal server error regardless of my status code is different from that.
My API return an IEnumerable where T is a simple object and I'm using Net 6 version.
Sample Code
[HttpGet]
public IHttpActionResult Get()
{
throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)
{
Content = new StringContent("Could not find.."),
ReasonPhrase = "Test not found"
});
return null;
}
Any idea?