【问题标题】:PasswordReset with WebSecurity in WebMatrix not workingWebMatrix 中使用 WebSecurity 的 PasswordReset 不起作用
【发布时间】:2013-05-29 20:15:09
【问题描述】:

可能重复 Webmatrix WebSecurity not authenticating

这是我的PasswordReset.cshtml 页面:

@{
Layout="Layout.cshtml";
var uID = "";
var newPass = "";
var confirmPass = "";
var token = "";
if(IsPost){
uID = Request.Form["userID"];
newPass = Request.Form["newPassword"];
confirmPass=Request.Form["confirmPassword"];
token=WebSecurity.GeneratePasswordResetToken(uID, 5);
WebSecurity.ResetPassword(token, newPass);
}else{
      Response.Redirect("Default");
      }
}

现在,错误消息是这样的:

“/”应用程序中的服务器错误。

编译错误

描述:在编译服务此请求所需的资源期间发生错误。请查看以下具体错误详情并适当修改您的源代码。

编译器错误消息:CS0103:当前上下文中不存在名称“userID”

来源错误:

Line 10: newPass = Request.Form["newPassword"];

Line 11: confirmPass = Request.Form["confirmPassword"];

Line 12: token = WebSecurity.GeneratePasswordResetToken(userID, 5);
 
Line 13: WebSecurity.ResetPassword(token, newPass); 

我认为代码是正确的,但我无法找出错误的原因。请帮忙。

【问题讨论】:

    标签: c# asp.net razor webmatrix


    【解决方案1】:

    该变量在上述上下文中不存在。您将 Request.Form 中的用户 ID 存储在 uId 中,您的意思是:

    WebSecurity.GeneratePasswordResetToken(uID, 5);
    

    【讨论】:

    • 是的,对不起。我的错。我是这个意思。
    • 但这仍然将我重定向到默认页面。我看不到用户输入新密码的 HTML 表单的其余部分。
    猜你喜欢
    • 2016-08-16
    • 2011-07-04
    • 1970-01-01
    • 2018-08-12
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多