Thursday, February 26, 2015

Possible return values for ASP.NET Web API IHttpActionResult methods

When reading about ASP.NET Web API 2 and the new IHttpActionResult return type for methods, it is not readily obvious what are all of the different variations of return types for the IHttpActionResult method at first glance.

If you look at the ASP.NET Web API 2 articles closely, however, you will find a reference to the System.Web.HttpResults namespace which contains all of the possible return types as listed in this MSDN article:

The possible return types for an ASP.NET Web API IHttpActionResult method are the following:

  • BadRequestErrorMessageResult
  • BadRequestResult
  • ConflictResult
  • CreatedAtRouteNegotiatedContentResult<T>
  • CreatedNegotiatedContentResult<T>
  • ExceptionResult
  • FormattedContentResult<T>
  • InternalServerErrorResult
  • InvalidModelStateResult
  • JsonResult<T>
  • NegotiatedContentResult<T>
  • NotFoundResult
  • OkNegotiatedContentResult<T>
  • OkResult
  • RedirectResult
  • RedirectToRouteResult
  • ResponseMessageResult
  • StatusCodeResult
  • UnauthorizedResult

No comments:

Post a Comment