我有以下错误:' 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;
}
}
答案 0 :(得分:8)
好的我找到了解决方案,因为我已经安装了nuget包,我所要做的就是以下内容:
return _userManager ?? HttpContext.**current**.GetOwinContext().GetUserManager<ApplicationUserManager>();