为什么asp.net-identity的保护级别导致Microsoft.Owin.Security.AuthenticationManager无法访问?

2026-03-30 12:261阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计235个文字,预计阅读时间需要1分钟。

为什么asp.net-identity的保护级别导致Microsoft.Owin.Security.AuthenticationManager无法访问?

我正在尝试实现ASP.NET Identity 2.0。在VS 2012中创建了一个MVC4项目,并使用NuGet命令安装了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中的内部类.
因此,我可以从AuthenticationManager派生一个类并调用公共方法SignIn()和SignOut().

在同一个程序集中有一个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-identity的保护级别导致Microsoft.Owin.Security.AuthenticationManager无法访问?

本文共计235个文字,预计阅读时间需要1分钟。

为什么asp.net-identity的保护级别导致Microsoft.Owin.Security.AuthenticationManager无法访问?

我正在尝试实现ASP.NET Identity 2.0。在VS 2012中创建了一个MVC4项目,并使用NuGet命令安装了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中的内部类.
因此,我可以从AuthenticationManager派生一个类并调用公共方法SignIn()和SignOut().

在同一个程序集中有一个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-identity的保护级别导致Microsoft.Owin.Security.AuthenticationManager无法访问?