本文介绍了FormsAuthentication Microst.AspNet.Identity.Owin.SignInManager.之间的区别进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET MVC的默认Project模板带有一个名为Microst.AspNet.Identity.Owin.SignInManager的类.此类用于验证用户

The default Project template of ASP.NET MVC comes with a class named Microst.AspNet.Identity.Owin.SignInManager. This class is used to authenticate users

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

I dont understand why should i use SignInManager instead of using simple FormsAuthentication in an ASP.NET MVC Project. What are the benefits of SignInManager?

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

Does it authenticate in a different way according to FormsAuthentication? Is it more secure then FormsAuthentication? What can i do else with SignInManager except authentication?

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

What is the relation between SignInManager and the code below? Does The SignInManager use the settings which are set below?

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))
    }
}); 

推荐答案

MembershipProvider 随ASP.NET 2中的 FormsAuthentication 一起提供.

MembershipProvider came with FormsAuthentication in ASP.NET 2.

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

ASP.NET Identity came with SignInManager in ASP.NET 5.

ASP.NET Identity是MembershipProvider的新版本.它提供的功能比旧版MembershipProvider还要多.

ASP.NET Identity is a new version of MembershipProvider. It offers a lot more features than legacy MembershipProvider.

例如,

  • 双重身份验证
  • 基于令牌的身份验证
  • 易于添加的自定义属性与MembershipProvider的比较
  • 从OWIN上下文获取UserManager实例
  • Two-factor authentication
  • Token-based authentication
  • Easy-to-add custom properties compare to MembershipProvider
  • Get instance of UserManager from the OWIN context

如果您不需要所有这些功能,则可以坚持使用 FormsAuthentication ,而无需 MembershipProvider 即可使用.

If you do not need all those features, you can stick with FormsAuthentication which can be used without MembershipProvider.

这篇关于FormsAuthentication Microst.AspNet.Identity.Owin.SignInManager.之间的区别进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:38