表单身份验证等效于Membership API

时间:2014-07-05 09:41:13

标签: c# asp.net-mvc asp.net-membership

我的网站管理门户只能由一个用户访问,因此我选择使用基本表单身份验证 -

public bool Authenticate(string username, string password)
{
    var authenticated = FormsAuthentication.Authenticate(username, password);
    if (authenticated)
        FormsAuthentication.SetAuthCookie(username, false);
    return authenticated;
}
...
<authentication mode="Forms">
  <forms loginUrl="~/login" timeout="2880">
    <credentials passwordFormat="SHA1">
      <user name="admin" password="ABC.." />
    </credentials>
  </forms>
</authentication>

最近我了解到FormsAuthentication.Authenticate方法已被弃用,我应该使用成员资格API。

允许我在web.config中存储凭据的FormsAuthentication.Authenticate等效成员资格API是什么?

1 个答案:

答案 0 :(得分:1)

我认为没有。我认为在web.config中存储凭据是API过时的原因。此外,还有一个比Membership更新的API - ASP.NET Identity。如果您要使用更新的API重写您的身份验证代码,请更好地使用ASP.NET身份。但是,如果您的用例实际上是一个用户,并且您并不担心安全问题,那么您可以将其保留下来。