asp.net-identity – 由于其保护级别,Microsoft.Owin.Security.A
发布时间:2020-12-16 09:25:51 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试实现ASP.NET Identity 2.0.我在VS 2012中创建了一个MVC4项目,并使用Nu Get命令安装了ASP.NET Identity 2.0软件包.我收到编译错误消息“Microsoft.Owin.Security.AuthenticationManager”由于其保护级别而无法访问,具有以下代码. 获取编译错误,因为
我正在尝试实现ASP.NET Identity 2.0.我在VS 2012中创建了一个MVC4项目,并使用Nu Get命令安装了ASP.NET Identity 2.0软件包.我收到编译错误消息“Microsoft.Owin.Security.AuthenticationManager”由于其保护级别而无法访问,具有以下代码.
获取编译错误,因为AuthenticationManager是程序集EntityFramework.dll中的内部类. 在同一个程序集中有一个AuthenticationManagerExtensions类.我怎样才能将它用于SignIn和SignOut? using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using System.Threading.Tasks; using Microsoft.Owin.Security; private async Task SignInAsync(ApplicationUser user,bool isPersistent) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var identity = await UserManager.CreateIdentityAsync( user,DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn( new AuthenticationProperties() { IsPersistent = isPersistent },identity); } 解决方法
此处使用的AuthenticationManager是当前Owin上下文的Authentication对象.通过在同一个类中添加以下属性来解决此问题.
private IAuthenticationManager AuthenticationManager { get { return HttpContext.GetOwinContext().Authentication; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – ASP.NET MVC – 在ActionFilter中访问控制器
- asp.net – RedirectToAction MVC2的问题 – 不能将类型“S
- asp.net – 视图状态中存储的项目的生命周期是多少?
- asp.net – 我们可以在视图状态中放置哪些类型的对象?
- asp.net – 如何在运行时更改页面位置
- asp.net-mvc – Knockout Js,JQuery UI Dialog和Partial vi
- asp.net-mvc-3 – 如何从ModelMetadata检索GroupName数据注
- asp.net – 如何在Repeater中查找控件
- asp.net – 如何在使用无cookie的静态内容服务器时使bundle
- asp.net – 如何在运行时设置ObjectDataSource选择参数
推荐文章
站长推荐
- asp.net – Application_Start和Application_OnS
- asp.net – 使用回发解析.Net页面
- asp.net – HtmlGenericControl(“br”)呈现两次
- asp.net – System.web.ui.page的替代品
- asp.net-mvc – 修改ActionFilter中的模型
- asp.net – 如何让Google不会将自定义404错误页面
- 浅谈ASP.NET MVC 防止跨站请求伪造(CSRF)攻击的实
- ASP.NET性能优化之让浏览器缓存动态网页的方法
- asp.net页面SqlCacheDependency缓存实例
- asp.net-mvc – 使用Repository/Service Pattern
热点阅读