"Microsoft.Owin.IOwinContext"不包含"GetUserManager"的定义且没有扩展方法? [英] 'Microsoft.Owin.IOwinContext' does not contain a definition for 'GetUserManager' and no extension method?
问题描述
以下代码是从Asp.Net Identity 2.0示例中复制的.
The following code is copied from the Asp.Net Identity 2.0 sample.
private ApplicationUserManager _userManager;
public ApplicationUserManager UserManager
{
get
{
return // Error
_userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
private set
{
_userManager = value;
}
}
但是会出现以下错误吗?
However it gets the following error?
错误3'Microsoft.Owin.IOwinContext'不包含'GetUserManager'的定义,并且找不到扩展方法'GetUserManager'接受类型为'Microsoft.Owin.IOwinContext'的第一个参数(您是否缺少使用指令还是程序集引用?)
Error 3 'Microsoft.Owin.IOwinContext' does not contain a definition for 'GetUserManager' and no extension method 'GetUserManager' accepting a first argument of type 'Microsoft.Owin.IOwinContext' could be found (are you missing a using directive or an assembly reference?)
更新:
Microsoft.AspNet.Identity.Owin.dll的版本2已存在于... \ packages \ Microsoft.AspNet.Identity.Owin.2.0.1 \ lib \ net45中.
The version 2 of Microsoft.AspNet.Identity.Owin.dll already exists in ...\packages\Microsoft.AspNet.Identity.Owin.2.0.1\lib\net45.
但是,在我的项目和示例之间,HttpContext.GetOwinContext()
的视图定义是不同的.我项目的前三行是
However, the view definition of HttpContext.GetOwinContext()
are different between my project and the sample. The first three lines of my project are
#region Assembly Microsoft.Owin.Host.SystemWeb.dll, v2.0.0.0
// C:\......\packages\Microsoft.Owin.Host.SystemWeb.2.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll
#endregion
样本为
#region Assembly Microsoft.Owin.Host.SystemWeb.dll, v2.1.0.0
// C:\....\sample\packages\Microsoft.Owin.Host.SystemWeb.2.1.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll
#endregion
但是我已经使用Neget将所有Owin Nuget软件包更新为最新版本.
But I already updated all Owin Nuget packages to the newest version using Neget.
推荐答案
扩展方法已移至其他命名空间,请尝试添加
The extension method was moved to a different namespace, try adding
using Microsoft.AspNet.Identity.Owin;
这篇关于"Microsoft.Owin.IOwinContext"不包含"GetUserManager"的定义且没有扩展方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!