ASP.Net身份 - HttpContext的有GetOwinContext没有扩展方法 [英] ASP.Net Identity - HttpContext has no extension method for GetOwinContext
问题描述
我已经下载,并成功从这里跑了ASP.Net身份示例:
<一href=\"https://github.com/rustd/AspnetIdentitySample\">https://github.com/rustd/AspnetIdentitySample
I have downloaded, and successfully ran the ASP.Net Identity sample from here: https://github.com/rustd/AspnetIdentitySample
我现在在我的项目实施ASP.Net身份框架中,已经碰到了一个问题,即推动了我疯了,整天... GetOwinContext()
不存在作为一个扩展方法我的HttpContext
I am now in the middle of implementing the ASP.Net Identity framework in my project and have ran into a problem, that has driven me mad all day... GetOwinContext()
does not exist as an extension method on my HttpContext
我实施类库的身份框架。我已经安装了所有最新的身份框架(pre-发布版本)和一切 - 除了这一点 - 是工作的罚款。
I am implementing the identity framework in class library. I have installed all the latest (pre-release version) of the Identity framework and everything - apart from this - is working fine.
我试图实现相同的code一样直接在我的控制器,并找到了同样的问题。
I have tried implementing the same code as the same direct in my controller, and find the same problem.
我清楚地缺少一个参考的地方,虽然我不知道..!..
I'm clearly missing a reference somewhere, though I have no idea what..!..
这是杀害我的code-块是:
The code-block that is killing me is:
private IAuthenticationManager AuthenticationManager
{
get
{
return HttpContext.GetOwinContext().Authentication;
}
}
我添加引用下面的 - 尝试这些都在我的类库,并直接在控制器上,他们没有为我工作...
I have added references to the following - tried these both in my class library and also direct on the controller, none of them work for me...
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using Microsoft.Owin;
using System.Web;
...这是推动我逼疯了....任何想法?
... this is driving me up the wall....any idea?
更新
我已经检查身份和放大器的版本; OWIN样品中,并确保我有相同的版本在我的解决方案。
I have checked the versions of Identity & OWIN in the sample, and have made sure I have the same versions in my solution.
越是这样,如果我搜索的样本对象浏览器为 GetOwinContext
我能找到的方法,但是当我在我的解决方案寻找它是无处可发现......我必须有一些图书馆过时,但无法找到它!
More so, if I search the object browser on the sample for GetOwinContext
I can find the method, however when I search for it in my solution it is nowhere to be found... I must have some library out of date, but can't find it!
推荐答案
哎呀!
我发现它 ...我没有一个额外的包,名为 Microsoft.Owin.Host.SystemWeb
I found it... I didn't have an extra package, called Microsoft.Owin.Host.SystemWeb
在我搜索和安装这一点,它的工作。
Once i searched and installed this, it worked.
现在 - 我不知道如果我只是错过了一切,虽然未找到引用这样的库或包通过各种教程去的时候。同时,当我安装了这一切身份的框架没有得到安装......不知道这只是我..
Now - i am not sure if i just missed everything, though found NO reference to such a library or package when going through various tutorials. It also didn't get installed when i installed all this Identity framework... Not sure if it were just me..
修改
虽然它在 Microsoft.Owin.Host.SystemWeb
组装是在的System.Web
命名空间的扩展方法,所以你需要有参考前者,并使用
后者。
EDIT
Although it's in the Microsoft.Owin.Host.SystemWeb
assembly it is an extension method in the System.Web
namespace, so you need to have the reference to the former, and be using
the latter.
这篇关于ASP.Net身份 - HttpContext的有GetOwinContext没有扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!