问题描述
我正在探索在WebMatrix.WebData.WebSecurity用于会员的Visual Studio示例web应用ASP.NET MVC的可能性(创建帐户,并指定一个用户登录,查看特定的页面等) 。但经过一番搜索,我发现也有可用于会员一System.Web.Security.FormsAuthentication类。
I am exploring the possibilities of ASP.NET MVC in the example webapplication of Visual Studio the WebMatrix.WebData.WebSecurity is used for Membership (creating accounts, and specify that a user is logged in to view a specific page etc.). But after some searching I found that there is also a System.Web.Security.FormsAuthentication class that can be used for Membership.
是否有人知道这两个类之间的差异/亲的利弊?以及何时使用WebSecurity以及何时使用FormsAuthentication? (和FormsAuthentication的也许一个明显的例子)
Does anybody know the differences/pro's and cons between these two classes? And when to use WebSecurity and when to use FormsAuthentication? (and maybe a clear example of FormsAuthentication)
在此先感谢
推荐答案
WebSecurity
在WebMatrix中2和ASP.NET MVC 4.依赖于<$ c的介绍$ C> SimpleMembershipProvider 。在幕后,它使用 FormsAuthentication
管理Cookie。所以我想,如果你正在开始一个新的项目,你会选择新的模式,如果这种模式适合您的需求。裸记住, SimpleMembershipProvider
公开比原来少提供商的功能。
WebSecurity
was introduced in WebMatrix 2 and ASP.NET MVC 4. It relies on the SimpleMembershipProvider
. Under the covers it uses FormsAuthentication
to manage cookies. So I guess that if you are starting a new project you would opt for the new model if this model fits your needs. Bare in mind that the SimpleMembershipProvider
exposes less functionality than the original provider.
最初的成员资格提供使用这反过来使用普通的ADO.NET查询数据库中的SqlMembershipProvider。
The original membership provider uses the SqlMembershipProvider which in turn uses plain ADO.NET to query the database.
该SimpleMembershipProvider使用新的数据库
类WebMatrix中推出来查询SQL数据库。
The SimpleMembershipProvider uses the new Database
class introduced in WebMatrix to query the SQL database.
这篇关于FormsAuthentication和WebSecurity的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!