Can't find Request.GetOwinContext

后端 未结 13 1275
北荒
北荒 2020-12-04 22:47

I have been searching for an hour trying to figure out why this isn\'t working.

I have a ASP.Net MVC 5 application with a WebAPI. I am trying to get Request.GetOwin

13条回答
  •  旧时难觅i
    2020-12-04 23:26

    This took me forever to find a simple answer: but what I did was use the Get extension of the single instance of the IOwinContext that was instantiated in the startup. So it came out like this:

    private readonly IOwinContext _iOwinContext = HttpContext.Current.GetOwinContext();
    
    public ApplicationUserManager UserManager
        {
            get
            {
                return _userManager ?? _iOwinContext.Get() ;
            }
            private set
            {
                _userManager = value;
            }
        }
    

提交回复
热议问题