Using ASP.NET Session for Lifetime Management (Unity)

前端 未结 7 2090
猫巷女王i
猫巷女王i 2020-12-10 11:59

I am considering using Unity to manage the lifetime of a custom user class instance. I am planning on extending the LifetimeManager with a custom ASP.NET session manager.

7条回答
  •  天命终不由人
    2020-12-10 12:17

    I would think that you need two services that you expose through unity (or one service that does both actions).

    Instead of storing the user object, store an interface implementation which exposes a method/property that will get the user object for you. In the ASP.NET case, you retrieve the user from the session. In the WinForm solution (or whatever), you can get it from the executing thread.

    You would also have a set method/property as well, which you would use to set the user.

提交回复
热议问题