【问题标题】:'System.Web.HttpContext' does not contain a definition for 'GetOwinContext'“System.Web.HttpContext”不包含“GetOwinContext”的定义
【发布时间】:2014-11-03 08:32:21
【问题描述】:

我有以下错误:“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;
        }
    }

【问题讨论】:

    标签: asp.net-mvc owin


    【解决方案1】:

    好的,我找到了解决方案,因为我已经安装了 nuget 包,我所要做的就是:

      return _userManager ?? HttpContext.**current**.GetOwinContext().GetUserManager<ApplicationUserManager>();
    

    【讨论】:

    • 你安装了哪个 Nuget 包?
    • Microsoft.Owin.Host.SystemWeb
    • 我错过了它的当前属性,有趣的是我在 OWIN 上找到的示例都有这样的问题
    猜你喜欢
    • 2015-10-31
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    相关资源
    最近更新 更多