表单身份验证相当于成员API



我的网站的管理门户只能由单个用户访问,正是出于这个原因,我选择使用基本表单身份验证-

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来代替。

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

我认为没有。我认为在web中存储凭证。配置是API过时的原因。此外,还有一个比会员制更新的API——ASP。净的身份。如果你打算用更新的API重写身份验证代码,最好使用ASP。净的身份。但是,如果您的用例实际上是一个用户,并且您并不真正担心安全性,那么您可以不去管它。

最新更新