OWIN Katana: Lifetime and Scale Confusion with AspNet.Identity

I am new to OWIN and I have implemented a solution using AspNet.Identity. There are several coded strings in the launch configuration, similar to the following ...

        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

      

Now every object (ApplicationDbContext, ApplicationUserManager, etc.) has a Create method that takes an Owin parameter and context. I'm not sure at what point the Create method is called, the lifespan and scope of the object. The following is what I believe in, but can anyone tell me if I got it right or misunderstood ...

  • Startup.Configuration is called only once when the application starts.
  • ApplicationUserManager will be created for each request
  • Executing HttpContext.GetOwinContext (). Get () will get the same ApplicationUserManager object every time it is called, it will not create a new one every time.
  • All objects I receive this way will be removed at the end of each request.
  • Objects are not persisted between requests.

Statement 5 is my real attraction. How would I like to say that the session-specific objects say that if I want to hold onto the ApplicationUser object during login without having to get it from the database every time? Also can I store specific application objects for caching?

Here's a link to where I came up with this understanding, but it doesn't talk about session or application scope ...

http://blogs.msdn.com/b/webdev/archive/2014/02/12/per-request-lifetime-management-for-usermanager-class-in-asp-net-identity.aspx

From the moment of writing this, I just realized that HttpContext has Session and Application properties that would have to host these scoped objects.

+3


source to share





All Articles