QuickDevGuide

Home › .NET Framework (Legacy & Enterprise)

ASP.NET Web API 2 — .NET Framework (Legacy & Enterprise)

Web API 2 builds HTTP/JSON services on .NET Framework. Controllers inherit ApiController and return data or IHttpActionResult. Feature API Routing config.MapHttpAttributeRoutes() + [Route], [RoutePrefix] Results Ok(x), Created(uri, x), NotFound(), BadRequest(ModelState), StatusCode(...) Binding [FromBody] complex types, [FromUri] query objects Content negotiation JSON (Json.NET) and XML formatters Cross-cutting message handlers, filters (ActionFilterAttribute, ExceptionFilterAttribute) Hosting IIS or OWIN self-host Docs Swashbuckle (Swagger) Use async Task<IHttpActionResult> for I/O, and configure camelCase JSON once in WebApiConfig.

Key Takeaways