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: https://msdn.microsoft.com/en-us/library/system.web.http.results%28v=vs.118%29.aspx

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