Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用于身份验证的Microst.AspNet.Identity.Owin.SignInManager.FormsAuthentication与Microst.AspNet.Identity.Owin.SignInManager.Forms之间的差异_C#_Asp.net_Asp.net Mvc_Authentication_Forms Authentication - Fatal编程技术网

C# 用于身份验证的Microst.AspNet.Identity.Owin.SignInManager.FormsAuthentication与Microst.AspNet.Identity.Owin.SignInManager.Forms之间的差异

C# 用于身份验证的Microst.AspNet.Identity.Owin.SignInManager.FormsAuthentication与Microst.AspNet.Identity.Owin.SignInManager.Forms之间的差异,c#,asp.net,asp.net-mvc,authentication,forms-authentication,C#,Asp.net,Asp.net Mvc,Authentication,Forms Authentication,ASP.NET MVC的默认项目模板附带一个名为Microst.AspNet.Identity.Owin.SignInManager的类。此类用于对用户进行身份验证 我不明白为什么我应该在ASP.NET MVC项目中使用SignInManager而不是简单的表单身份验证。SignInManager的好处是什么 它是否根据FormsAuthentication以不同的方式进行身份验证?它比身份验证更安全吗?除了身份验证之外,我还可以使用SignInManager做什么 SignInManager与

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

我不明白为什么我应该在ASP.NET MVC项目中使用SignInManager而不是简单的表单身份验证。SignInManager的好处是什么

它是否根据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))
    }
}); 
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/Login”),
Provider=新CookieAuthenticationProvider
{
//允许应用程序在用户登录时验证安全戳。
//这是一种安全功能,在您更改密码或向帐户添加外部登录时使用。
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromMinutes(30),
regenerateIdentity:(管理器,用户)=>user.GenerateUserIdentityAsync(管理器))
}
}); 

表单身份验证是ASP.NET身份验证框架的旧版本。反对使用表单身份验证的一个真正可靠的理由是


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

会员身份提供方在ASP.NET 2中附带了表单身份验证

ASP.NET Identity与ASP.NET 5中的SignInManager一起出现

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

比如说,

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

如果您不需要所有这些功能,您可以坚持使用FormsAuthentication,它可以在没有会员资格提供商的情况下使用

这个想法是为了让OWIN不受平台的影响。它是ASP.NET应用程序和运行它的平台之间的“中间件”。表单身份验证是为IIS上的ASP.NET构建的。OWIN可以使用谷歌和Facebook等其他提供商


看看这篇文章:

这并没有真正回答这个问题。ASP.NET MVC默认使用ASP.NET标识,因为版本5。以前MVC使用SimpleMembership,它是ASP.NET成员资格的包装,使用表单身份验证。这也不是真的。Identity是SimpleMembership的替代品谢谢,请帮我更新这个问题,使它更有用/更准确。@DavidG:这怎么不是真的?是的,Identity显然是对成员身份的替代,但它并没有改变这样一个事实,即如果您今天开始一个新的MVC4项目,它将与Forms Auth一起使用SimpleMembership。特别是,对于现有的MVC4项目,转换为身份是非常重要的?这两个是不同的野兽?我听到的身份支持声明,但token与我不知道的声明有何不同。因此,我的请求是,如果有人知道代币和索赔之间的区别,请在这里解释。thanks@MonojitSarkar基于令牌的身份验证是ASP.Net标识的一部分。默认情况下,ASP.Net Identity在后台使用基于声明的授权,尽管您不必使用它(这并不常见)。如果您仍然有问题,是否可以创建一个新问题?我很高兴能帮助你。告诉我基于令牌的身份验证和基于声明的身份验证是两件不同的事情。如果是,那么它们有什么不同。我不能创建一个新的帖子,因为如果我发帖,人们会给我投反对票。