AspNetRequestLifestyle Class

Simple Injector

Note: This API is now obsolete.

Defines a lifestyle that caches instances during the execution of a single ASP.NET Request. Unless explicitly stated otherwise, instances created by this lifestyle will be disposed at the end of the request. Do note that this lifestyle requires the UseSimpleInjectorAspNetRequestScoping. to be registered in the Web API configuration.
Inheritance Hierarchy

SimpleInjector.LifestylesAsyncScopedLifestyle
  SimpleInjector.Integration.AspNetCoreAspNetRequestLifestyle

Namespace:  SimpleInjector.Integration.AspNetCore
Assembly:  SimpleInjector.Integration.AspNetCore (in SimpleInjector.Integration.AspNetCore.dll) Version: 4.1.0-alpha1
Syntax

[ObsoleteAttribute("This lifestyle is obsolete. Please use SimpleInjector.Lifestyles.AsyncScopedLifestyle instead.", 
	false)]
public sealed class AspNetRequestLifestyle : AsyncScopedLifestyle
Constructors

  NameDescription
Public methodAspNetRequestLifestyle
Initializes a new instance of the AspNetRequestLifestyle class. The created and cached instance will be disposed when the Web API request ends, and when the created object implements IDisposable.
Public methodAspNetRequestLifestyle(Boolean) Obsolete.
Initializes a new instance of the AspNetRequestLifestyle class.
Top
Examples

The following example shows the usage of the AspNetRequestLifestyle class:
C#
var container = new Container();
container.Options.DefaultScopedLifestyle = new AspNetRequestLifestyle();

container.Register<IUnitOfWork, EntityFrameworkUnitOfWork>(Lifestyle.Scoped);
See Also

Reference