I have the following error :'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' whenever I debug my project. this error is in the web API page, although it doesn't show an error in the default AccounController.cs and the nuget package is installed.what is missing?
我有以下错误:每当我调试我的项目时,'System.Web.HttpContext'都不包含'GetOwinContext'的定义。此错误发生在Web API页面中,虽然它在默认的AccounController.cs中没有显示错误并且安装了nuget包。缺少什么?
using IdentitySample.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using System.Web;
using System.Threading.Tasks;
using task.Models;
using System.Globalization;
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
1 个解决方案
#1
7
ok I found the solution since I already installed the nuget package all I have to do is the following:
好的,我找到了解决方案,因为我已经安装了nuget包,我所要做的就是以下内容:
return _userManager ?? HttpContext.**current**.GetOwinContext().GetUserManager<ApplicationUserManager>();
#1
7
ok I found the solution since I already installed the nuget package all I have to do is the following:
好的,我找到了解决方案,因为我已经安装了nuget包,我所要做的就是以下内容:
return _userManager ?? HttpContext.**current**.GetOwinContext().GetUserManager<ApplicationUserManager>();