2013-05-29 37 views
0

可能重複 Webmatrix WebSecurity not authenticatingPasswordReset在WebMatrix中WebSecurity不工作

這是我的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"); 
     } 
} 

現在,該錯誤信息是這樣的:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'userID' does not exist in the current context

Source Error:

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); 

我認爲代碼是正確的,但我不能f找出錯誤的原因。請幫忙。

回答

0

該變量在上述上下文中不存在。您正在將您的用戶ID從Request.Form存儲在uId中,您的意思是:

WebSecurity.GeneratePasswordResetToken(uID, 5); 
+0

對,對不起。我的錯。我的意思是。 –

+0

但仍然將我重定向到默認頁面。 我看不到我的HTML表單的其餘部分,用戶輸入新密碼。 –