asp.net-mvc-4 – 使用web.config中的凭据设置配置成员资格提供程序

我正在尝试在ASP.NET MVC4应用程序中实现表单身份验证,我只有一个用户将通过身份验证来执行一些管理活动.

<authentication mode="Forms">
  <forms timeout="2880" loginUrl="~/Admin/Login" slidingExpiration="true">
    <credentials passwordFormat="Clear">
      <user name="user" password="password"/>
    </credentials>
  </forms>
</authentication>

当我尝试使用FormsAuthentication.ValidateUser方法时,我得到一个过时的警告,我应该使用现在的Membership类.

我的问题是如何在web.config中配置成员资格提供程序以使用web.config中的凭据设置?我应该在name属性中指定哪个提供程序?

最佳答案 遗憾的是,正如您所描述的那样,没有内置的成员资格提供程序来存储web.config中的凭据的机制.您可以编写自己的方法来调用
FormsAuthentication.Authenticate方法,或者从您自己的自定义登录控件的代码隐藏中调用它.

点赞