Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ExceptionHandlerExtensions.UseExceptionHandler Method

Definition

Namespace:
Microsoft.AspNetCore.Builder
Assembly:
Microsoft.AspNetCore.Diagnostics.dll
Package:
Microsoft.AspNetCore.Diagnostics v1.0.0
Package:
Microsoft.AspNetCore.Diagnostics v1.1.0
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Diagnostics v2.0.0
Package:
Microsoft.AspNetCore.Diagnostics v2.1.0
Package:
Microsoft.AspNetCore.Diagnostics v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
UseExceptionHandler(IApplicationBuilder)

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

UseExceptionHandler(IApplicationBuilder, ExceptionHandlerOptions)

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

UseExceptionHandler(IApplicationBuilder, Action<IApplicationBuilder>)

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

UseExceptionHandler(IApplicationBuilder, String)

Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started.

UseExceptionHandler(IApplicationBuilder, String, Boolean)

Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started.

UseExceptionHandler(IApplicationBuilder)

Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Builder::IApplicationBuilder ^ UseExceptionHandler(Microsoft::AspNetCore::Builder::IApplicationBuilder ^ app);
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseExceptionHandler(this Microsoft.AspNetCore.Builder.IApplicationBuilder app);
static member UseExceptionHandler : Microsoft.AspNetCore.Builder.IApplicationBuilder -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function UseExceptionHandler (app As IApplicationBuilder) As IApplicationBuilder

Parameters

Returns

Applies to

UseExceptionHandler(IApplicationBuilder, ExceptionHandlerOptions)

Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Builder::IApplicationBuilder ^ UseExceptionHandler(Microsoft::AspNetCore::Builder::IApplicationBuilder ^ app, Microsoft::AspNetCore::Builder::ExceptionHandlerOptions ^ options);
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseExceptionHandler(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Microsoft.AspNetCore.Builder.ExceptionHandlerOptions options);
static member UseExceptionHandler : Microsoft.AspNetCore.Builder.IApplicationBuilder * Microsoft.AspNetCore.Builder.ExceptionHandlerOptions -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function UseExceptionHandler (app As IApplicationBuilder, options As ExceptionHandlerOptions) As IApplicationBuilder

Parameters

Returns

Applies to

UseExceptionHandler(IApplicationBuilder, Action<IApplicationBuilder>)

Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Builder::IApplicationBuilder ^ UseExceptionHandler(Microsoft::AspNetCore::Builder::IApplicationBuilder ^ app, Action<Microsoft::AspNetCore::Builder::IApplicationBuilder ^> ^ configure);
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseExceptionHandler(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> configure);
static member UseExceptionHandler : Microsoft.AspNetCore.Builder.IApplicationBuilder * Action<Microsoft.AspNetCore.Builder.IApplicationBuilder> -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function UseExceptionHandler (app As IApplicationBuilder, configure As Action(Of IApplicationBuilder)) As IApplicationBuilder

Parameters

Returns

Applies to

UseExceptionHandler(IApplicationBuilder, String)

Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs
Source:
ExceptionHandlerExtensions.cs

Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Builder::IApplicationBuilder ^ UseExceptionHandler(Microsoft::AspNetCore::Builder::IApplicationBuilder ^ app, System::String ^ errorHandlingPath);
public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseExceptionHandler(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, string errorHandlingPath);
static member UseExceptionHandler : Microsoft.AspNetCore.Builder.IApplicationBuilder * string -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function UseExceptionHandler (app As IApplicationBuilder, errorHandlingPath As String) As IApplicationBuilder

Parameters

errorHandlingPath
String

Returns

Applies to

UseExceptionHandler(IApplicationBuilder, String, Boolean)

Source:
ExceptionHandlerExtensions.cs

Adds a middleware to the pipeline that will catch exceptions, log them, reset the request path, and re-execute the request. The request will not be re-executed if the response has already started.

public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseExceptionHandler(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, string errorHandlingPath, bool createScopeForErrors);
static member UseExceptionHandler : Microsoft.AspNetCore.Builder.IApplicationBuilder * string * bool -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function UseExceptionHandler (app As IApplicationBuilder, errorHandlingPath As String, createScopeForErrors As Boolean) As IApplicationBuilder

Parameters

errorHandlingPath
String

The String path to the endpoint that will handle the exception.

createScopeForErrors
Boolean

Whether or not to create a new IServiceProvider scope.

Returns

Applies to


Feedback

Was this page helpful?