WebSecurity ResetPassword 方法
websecurity - resetpassword()

定義
resetpassword() 方法使用密碼令牌重置用戶密碼。
c# 和 vb 語(yǔ)法
websecurity.resetpassword(passwordresettoken,newpassword)
參數(shù)
參數(shù) | 類(lèi)型 | 描述 |
---|---|---|
passwordresettoken | string | 密碼令牌 |
newpassword | string | 新密碼 |
返回值
類(lèi)型 | 描述 |
---|---|
boolean | 如果密碼已更改,則返回 true,否則返回 false。 |
錯(cuò)誤和異常
在下面的情況下,任何對(duì) websecurity 對(duì)象的訪問(wèn)將拋出一個(gè) invalidoperationexception:
- initializedatabaseconnection() 方法沒(méi)有被調(diào)用
- simplemembership 沒(méi)有初始化(或者在網(wǎng)站配置中禁用)
備注
如果用戶已忘記密碼,請(qǐng)使用 resetpassword 方法。
resetpassword 方法要求一個(gè)密碼重置令牌。
確認(rèn)令牌可通過(guò) createaccount()、 createuserandaccount() 或 generatepasswordresettoken() 方法創(chuàng)建。
密碼可通過(guò)代碼重置,但是一般過(guò)程是發(fā)送電子郵件給用戶(帶有令牌和指向頁(yè)面的鏈接),這樣用戶就可以通過(guò)新的令牌確認(rèn)新的密碼:
@{
newpassword = request["newpassword"];
confirmpassword = request["confirmpassword"];
token = request["token"];
if ispost
{
??? // input testing is ommitted here to save space
??? retunvalue = resetpassword(token, newpassword);
}
}
<h1>change password</h1>
<form method="post" action="">
<label for="newpassword">new password:</label>
<input type="password" id="newpassword" name="newpassword" title="new password" />
<label for="confirmpassword">confirm password:</label>
<input type="password" id="confirmpassword" name="confirmpassword" title="confirm new password" />
<label for="token">pasword token:</label>
<input type="text" id="token" name="token" title="password token" />
<p class="form-actions">
<input type="submit" value="change password" title="change password" />
</p>
</form>
newpassword = request["newpassword"];
confirmpassword = request["confirmpassword"];
token = request["token"];
if ispost
{
??? // input testing is ommitted here to save space
??? retunvalue = resetpassword(token, newpassword);
}
}
<h1>change password</h1>
<form method="post" action="">
<label for="newpassword">new password:</label>
<input type="password" id="newpassword" name="newpassword" title="new password" />
<label for="confirmpassword">confirm password:</label>
<input type="password" id="confirmpassword" name="confirmpassword" title="confirm new password" />
<label for="token">pasword token:</label>
<input type="text" id="token" name="token" title="password token" />
<p class="form-actions">
<input type="submit" value="change password" title="change password" />
</p>
</form>
技術(shù)數(shù)據(jù)
名稱 | 值 |
---|---|
namespace | webmatrix.webdata |
assembly | webmatrix.webdata.dll |

相關(guān)文章
- ASP.NET
- ASP.NET Web Pages 布局
- ASP.NET Web Pages 全局文件
- ASP.NET Web Pages HTML 表單
- ASP.NET Web Pages 文件
- ASP.NET Web Pages 類(lèi)參考手冊(cè)
- ASP.NET Web Pages WebMail 參考手冊(cè)
- ASP.NET Razor C# 邏輯
- ASP.NET Razor VB 循環(huán)和數(shù)組
- ASP.NET MVC Web 應(yīng)用程序
- ASP.NET MVC 控制器
- ASP.NET MVC 視圖
- ASP.NET MVC 安全
- ASP.NET MVC HTML 幫助器
- ASP.NET Web Forms 教程
- ASP.NET 事件句柄
- ASP.NET Web 表單
- ASP.NET Button 控件
- ASP.NET Repeater 控件
- ASP.NET DataList 控件