检索 ASP.NET 成员资格安全问题
我正在实现一个重置密码 aspx 页面,在该页面中,我使用向导执行以下操作。
- 我要求用户提供他/她的用户名,在继续之前检查以确保用户名确实存在。
- 在第二个视图中,我想要求用户回答他/她的安全问题。我想显示问题并验证他们的答案是什么,如果有效,则继续第三步。 (目前,我不确定如何检索要在第二个视图中显示的安全问题。)
- 在第三个视图中,要求用户输入新密码。
我知道如何在没有旧密码的情况下更改密码,但似乎无法弄清楚如何获取安全问题。
有人有什么想法吗?
I am implementing a reset password aspx page and in that page, I am doing the following with a Wizard.
- I am asking the user for his/her username, checking to make sure username does exist before moving on.
- In the second view, I want to ask the user to answer his/her security question. I want to display the question and validate what their answer is, and if valid, continue to third step. (At moment, I'm not sure how to retrieve the security question to display in the second.)
- In third view, ask user to enter in new password.
I understand how to go about changing the password even without the old password, but just can't seem to figure out how to get the security question.
Anyone have any ideas??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Membership.GetUser().PasswordQuestion
包含安全问题。Membership.GetUser().ResetPassword(securityQuestionAnswer)
将为用户生成一个新的随机密码。然后您可以通过电子邮件将此信息发送给用户。http://msdn.microsoft.com/en-us/library/d90zte4w.aspx
如果需要密码答案并且提供了不正确的密码答案,则成员资格提供程序将抛出
MembershipPasswordException
。如果您想允许用户输入密码,您可以检查以确保不会引发此异常,然后更改密码。Membership.GetUser().PasswordQuestion
contains the Security Question.Membership.GetUser().ResetPassword(securityQuestionAnswer)
will generate a new random password for the user. You can then email this to the user.http://msdn.microsoft.com/en-us/library/d90zte4w.aspx
If a password answer is required and an incorrect password answer is supplied, a
MembershipPasswordException
is thrown by the membership provider. If you wanted to allow the user to enter a password, you could check to ensure that this exception is not thrown, then change the password.