FormsAuthentication和WebSecurity之间的区别

我正在探索ASP.NET MVC的可能性,在Visual Studio的示例Web应用程序中,WebMatrix.WebData.WebSecurity用于成员资格(创建帐户,并指定用户登录以查看特定页面等)。 但经过一些搜索后,我发现还有一个可用于成员资格的System.Web.Security.FormsAuthentication类。

有谁知道这两个class级之间的差异/利弊? 何时使用WebSecurity以及何时使用FormsAuthentication? (也许是FormsAuthentication的一个明显例子)

提前致谢

WebSecurity是在WebMatrix 2和ASP.NET MVC 4中引入的。它依赖于SimpleMembershipProvider 。 在封面下,它使用FormsAuthentication来管理cookie。 所以我想如果你开始一个新项目,如果这个模型符合你的需要,你会选择新的模型。 请记住, SimpleMembershipProvider公开的function少于原始提供程序。

原始成员资格提供程序使用SqlMembershipProvider,后者又使用普通ADO.NET查询数据库。

SimpleMembershipProvider使用WebMatrix中引入的新Database类来查询SQL数据库。

旧的ASP.NET成员资格提供程序和SimpleMembershipProvider之间的主要区别在这篇好文章中有解释 – http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and -the-新-ASP净4-5-web的表单和-ASP净MVC -4- templates.aspx

使用SimpleMembershipProvider(WebMatrix.WebData.WebSecurity)比旧的ASP.NET成员资格提供程序(或通用提供程序)更好