FormsAuthentication Microst.AspNet.Identity.Owin.SignInManager.to之间的区别

MOD*_*MOD 10 c# asp.net authentication asp.net-mvc forms-authentication

ASP.NET MVC的默认项目模板附带了一个名为Microst.AspNet.Identity.Owin.SignInManager的类.此类用于验证用户身份

我不明白为什么我应该使用SignInManager而不是在ASP.NET MVC项目中使用简单的FormsAuthentication.SignInManager有什么好处?

它是否根据FormsAuthentication以不同的方式进行身份验证?它比FormsAuthentication更安全吗?除了身份验证之外,我还可以使用SignInManager做什么?

SignInManager和下面的代码之间有什么关系?SignInManager是否使用下面设置的设置?

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        // Enables the application to validate the security stamp when the user logs in.
        // This is a security feature which is used when you change a password or add an external login to your account.  
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
            validateInterval: TimeSpan.FromMinutes(30),
            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
    }
}); 
Run Code Online (Sandbox Code Playgroud)

Win*_*Win 9

MembershipProvider在ASP.NET 2中附带FormsAuthentication.

ASP.NET身份随ASP.NET 5中的SignInManager一起提供.

ASP.NET Identity是MembershipProvider的新版本.它提供了比传统MembershipProvider更多的功能.

例如,

  • 双因素身份验证
  • 基于令牌的身份验证
  • 与MembershipProvider相比,易于添加的自定义属性
  • 从OWIN上下文中获取UserManager的实例

如果您不需要所有这些功能,您可以坚持使用可以在没有MembershipProvider的情况下使用的FormsAuthentication.


Luk*_*uke 3

表单身份验证是旧版本的 ASP.NET 身份验证框架。反对使用表单身份验证的一个真正充分的理由是它已被弃用

最新版本的 Visual Studio 中 ASP.NET MVC 的默认模板具有ASP.NET Identity Framework的实现,因此使用SignInManager. 我相信使用 ASP.NET Identity 的主要优点之一是它可以作为 OWIN 中间件托管,这意味着它不依赖System.Web于您的 Web 应用程序。

  • 这并不能真正回答问题。 (4认同)