ASP.NET MVC 4, lanzar HttpException vs return HttpStatusCodeResult?
Estoy desarrollando un servicio RESTful y quiero devolver 400 para todas las URL no compatibles.
Mi pregunta es¿Cuándo debo elegir el método 1 sobre el método 2 y viceversa?
//method 1
public ActionResult Index()
{
//The url is unsupported
throw new HttpException(400, "Bad Request");
}
Este parece ser mejor?
//method 2
public ActionResult Index()
{
//The url is unsupported
return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Bad Request");
}