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

有人知道这两个类别之间的区别/优点和缺点吗?何时使用WebSecurity以及何时使用FormsAuthentication? (也许是FormsAuthentication的一个清晰示例)

提前致谢

最佳答案

WebSecurity在WebMatrix 2和ASP.NET MVC 4中引入。它依赖于SimpleMembershipProvider。在幕后,它使用FormsAuthentication来管理cookie。因此,我想如果您要启动一个新项目,并且该模型符合您的需求,那么您将选择该新模型。切记SimpleMembershipProvider公开的功能少于原始提供程序。

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

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

关于c# - FormsAuthentication和WebSecurity之间的区别,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12679050/

10-11 20:34