作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要重写很多 asp.net 成员(member)资料,因为它不能满足我的需求。所以在我的自定义验证方法中,如果失败,我会检查他们的密码。我捕获了aspnet_membership
maxInvalidPasswordAttempts 列并将其加 1。
所以在我的 web.config 中我将它设置为 10。所以我想从 web.config 中获取值并与用户拥有的值进行比较。我怎样才能做到这一点?
另外我想当我在 if 语句中进行比较时,我会将用户锁定吗?
最佳答案
您应该在提供程序的 Initialize 方法中从 web.config 获取配置值,如下所示:
public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
throw new ArgumentNullException("config");
// Initialize the abstract base class.
base.Initialize(name, config);
pApplicationName = GetConfigValue(config["applicationName"],
System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
pMaxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
// ...
关于asp.net - 如何从 web.config 中获取 maxInvalidPasswordAttempts?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1296108/
我是一名优秀的程序员,十分优秀!