gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 13:13:18 26 4
gpt4 key购买 nike

我正在尝试在 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方法或从您自己的自定义登录控件的代码隐藏中调用此方法。

关于asp.net-mvc-4 - 使用 web.config 中的凭据设置来配置成员资格提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13291016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com