If the action returns an [HttpResponseMessage](https://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage.aspx), Web API converts the return value directly into an HTTP response message, using the properties of the **HttpResponseMessage** object to populate the response.
This option gives you a lot of control over the response message. For example, the following controller action sets the Cache-Control header.
If you pass a domain model to the **CreateResponse** method, Web API uses a [media formatter](../formats-and-model-binding/media-formatters.md) to write the serialized model into the response body.
Web API uses the Accept header in the request to choose the formatter. For more information, see [Content Negotiation](../formats-and-model-binding/content-negotiation.md).
The **IHttpActionResult** interface was introduced in Web API 2. Essentially, it defines an **HttpResponseMessage** factory. Here are some advantages of using the **IHttpActionResult** interface:
If a controller action returns an **IHttpActionResult**, Web API calls the **ExecuteAsync** method to create an **HttpResponseMessage**. Then it converts the **HttpResponseMessage** into an HTTP response message.
Here is a simple implementaton of **IHttpActionResult** that creates a plain text response:
More often, you will use the **IHttpActionResult** implementations defined in the **[System.Web.Http.Results](https://msdn.microsoft.com/en-us/library/system.web.http.results.aspx)** namespace. The **ApiController** class defines helper methods that return these built-in action results.
In the following example, if the request does not match an existing product ID, the controller calls [ApiController.NotFound](https://msdn.microsoft.com/en-us/library/system.web.http.apicontroller.notfound.aspx) to create a 404 (Not Found) response. Otherwise, the controller calls [ApiController.OK](https://msdn.microsoft.com/en-us/library/dn314591.aspx), which creates a 200 (OK) response that contains the product.
For all other return types, Web API uses a [media formatter](../formats-and-model-binding/media-formatters.md) to serialize the return value. Web API writes the serialized value into the response body. The response status code is 200 (OK).
A disadvantage of this approach is that you cannot directly return an error code, such as 404. However, you can throw an **HttpResponseException** for error codes. For more information, see [Exception Handling in ASP.NET Web API](../error-handling/exception-handling.md).
Web API uses the Accept header in the request to choose the formatter. For more information, see [Content Negotiation](../formats-and-model-binding/content-negotiation.md).