SimpleInjectorAspNetCoreIntegrationExtensionsGetRequiredRequestServiceT Method

Simple Injector
Get service of type T from the list of request-specific services of the application builder. This preserves the lifestyle of the registered component.

Namespace:  SimpleInjector
Assembly:  SimpleInjector.Integration.AspNetCore (in SimpleInjector.Integration.AspNetCore.dll) Version: 5.0.0
Syntax

public static T GetRequiredRequestService<T>(
	this IApplicationBuilder builder
)

Parameters

builder
Type: IApplicationBuilder
The IApplicationBuilder to retrieve the service object from.

Type Parameters

T
The type of service object to get.

Return Value

Type: T
A service object of type T.

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

ExceptionCondition
InvalidOperationExceptionThrown when the method is called outside the context of a web request, or when there is no service of type T.
See Also

Reference