Adds a middleware type to the application's request pipeline. The middleware will be resolved from
the supplied the Simple Injector container. The middleware will be added to the
container for verification.
Namespace: SimpleInjector
Assembly: SimpleInjector.Integration.AspNetCore (in SimpleInjector.Integration.AspNetCore.dll) Version: 5.0.0
Syntax
public static IApplicationBuilder UseMiddleware( this IApplicationBuilder app, Type middlewareType, Container container )
Parameters
- app
- Type: IApplicationBuilder
The IApplicationBuilder instance. - middlewareType
- Type: SystemType
The middleware type that needs to be applied. This type must implement IMiddleware. - container
- Type: SimpleInjectorContainer
The container to resolve middlewareType from.
Return Value
Type: IApplicationBuilderThe supplied IApplicationBuilder instance.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IApplicationBuilder. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when one of the arguments is a null reference. |
ArgumentException | Thrown when the middlewareType does not derive from IMiddleware, is an open-generic type, or not a concrete constructable type. |
See Also