How exactly IAppBuilder.CreatePerOwinContext should be used?

后端 未结 2 2022
慢半拍i
慢半拍i 2020-12-19 07:17

I\'m confused on how the OWIN CreatePerOwinContext method is to be used. As far as I can see it\'s a poor mans DI mechanism. Yet, I fail to see how to use it.

We can

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 07:33

    You can use typeof to get the key parameter:

    HttpContext.GetOwinContext().Get(typeof(ApplicationDbContext).ToString());
    

    Also, Microsoft.AspNet.Identity.Owin assembly contains the parameterless version of Get() method, so you can use it if you already have ASP.NET Identity in your project.

提交回复
热议问题