1
var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
{
ReasonPhrase = "Nenhum produto encontrado"
};
throw new HttpResponseException(resp);
That code should return
404 No products found
But for some reason it’s not working. Any ideas? I’m using Visual Studio 2013 and IIS Express.
I think it’s your test interface that doesn’t read the
ReasonPhrase
. Have you tried testing using an Ajax request like this? http://www.codeguru.com/csharp/.net/asp/handling-exceptions-in-asp.net-web-api.htm– Leonel Sanches da Silva
That’s right @Ciganomorrisonmendez...
– Tiago César Oliveira
In these situations the Fiddler is your best friend.
– Paulo Morgado
@Paulomorgado I suspected that it was something of the type, and now that confirmed I started to use it...
– Tiago César Oliveira