Skip to content

Using Microsoft.Extensions.DependencyInjection with ASP.NET 4.x Scoped Services Are Singletons #3172

Closed
@scottsauber

Description

@scottsauber

Using the code found on this blog post: http://scottdorman.github.io/2016/03/17/integrating-asp.net-core-dependency-injection-in-mvc-4/ results in Scoped Services that are really Singletons, because CreateScope() is never called.

Are there any examples of using Microsoft.Extensions.DependencyInjection (M.E.DI) with ASP.NET 4?

The reason why I want to use M.E.DI instead of SimpleInjector, Autofac, Ninject, etc. is because we have a customer-facing app that is built on ASP.NET Core and uses Identity. Then we have an existing "back-office" app that already does a bunch of stuff, one of them being manage users for the customer-facing app.

We wanted to use M.E.DI so we can share the configuration of things like UserManager between the two applications easily. Also handwiring up all the dependencies that ASP.NET Core Identity has is non-trivial, and want to get the free updates in case new services are required in future updates that services.AddIdentity takes care of.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions