ExceptionHandlerServiceCollectionExtensions.AddExceptionHandler Method
Definition
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
AddExceptionHandler(IServiceCollection, Action<ExceptionHandlerOptions>) |
Adds services and options for the exception handler middleware. |
AddExceptionHandler<T>(IServiceCollection) |
Adds an |
AddExceptionHandler<TService>(IServiceCollection, Action<ExceptionHandlerOptions,TService>) |
Adds services and options for the exception handler middleware. |
AddExceptionHandler(IServiceCollection, Action<ExceptionHandlerOptions>)
Adds services and options for the exception handler middleware.
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddExceptionHandler (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Builder.ExceptionHandlerOptions> configureOptions);
static member AddExceptionHandler : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Builder.ExceptionHandlerOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddExceptionHandler (services As IServiceCollection, configureOptions As Action(Of ExceptionHandlerOptions)) As IServiceCollection
Parameters
- services
- IServiceCollection
The IServiceCollection for adding services.
- configureOptions
- Action<ExceptionHandlerOptions>
A delegate to configure the ExceptionHandlerOptions.
Returns
Applies to
AddExceptionHandler<T>(IServiceCollection)
Adds an IExceptionHandler
implementation to services. IExceptionHandler
implementations are used by the exception handler middleware to handle unexpected request exceptions.
Multiple handlers can be added and they're called by the middleware in the order they're added.
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddExceptionHandler<T> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services) where T : class, Microsoft.AspNetCore.Diagnostics.IExceptionHandler;
static member AddExceptionHandler : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'T : null and 'T :> Microsoft.AspNetCore.Diagnostics.IExceptionHandler)
<Extension()>
Public Function AddExceptionHandler(Of T As {Class, IExceptionHandler}) (services As IServiceCollection) As IServiceCollection
Type Parameters
- T
The type of the exception handler implementation.
Parameters
- services
- IServiceCollection
The IServiceCollection for adding services.
Returns
The modified IServiceCollection.
Applies to
AddExceptionHandler<TService>(IServiceCollection, Action<ExceptionHandlerOptions,TService>)
Adds services and options for the exception handler middleware.
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddExceptionHandler<TService> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.AspNetCore.Builder.ExceptionHandlerOptions,TService> configureOptions) where TService : class;
static member AddExceptionHandler : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.AspNetCore.Builder.ExceptionHandlerOptions, 'Service (requires 'Service : null)> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Service : null)
<Extension()>
Public Function AddExceptionHandler(Of TService As Class) (services As IServiceCollection, configureOptions As Action(Of ExceptionHandlerOptions, TService)) As IServiceCollection
Type Parameters
- TService
Parameters
- services
- IServiceCollection
The IServiceCollection for adding services.
- configureOptions
- Action<ExceptionHandlerOptions,TService>
A delegate to configure the ExceptionHandlerOptions.