--- title: Handle errors in ASP.NET Core web APIs author: rick-anderson description: Learn about error handling with ASP.NET Core web APIs. monikerRange: '>= aspnetcore-3.1' ms.author: riande ms.custom: mvc ms.date: 11/09/2021 uid: web-api/handle-errors --- # Handle errors in ASP.NET Core web APIs :::moniker range=">= aspnetcore-6.0" This article describes how to handle errors and customize error handling with ASP.NET Core web APIs. ## Developer Exception Page The [Developer Exception Page](xref:fundamentals/error-handling) shows detailed stack traces for server errors. It uses to capture synchronous and asynchronous exceptions from the HTTP pipeline and to generate error responses. For example, consider the following controller action, which throws an exception: :::code language="csharp" source="handle-errors/samples/6.x/HandleErrorsSample/Controllers/ErrorsController.cs" id="snippet_Throw"::: When the Developer Exception Page detects an unhandled exception, it generates a default plain-text response similar to the following example: ```console HTTP/1.1 500 Internal Server Error Content-Type: text/plain; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked System.Exception: Sample exception. at HandleErrorsSample.Controllers.ErrorsController.Get() in ... at lambda_method1(Closure , Object , Object[] ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() ... ``` If the client requests an HTML-formatted response, the Developer Exception Page generates a response similar to the following example: ```console HTTP/1.1 500 Internal Server Error Content-Type: text/html; charset=utf-8 Server: Kestrel Transfer-Encoding: chunked Internal Server Error