@* 若您在使用組合,請移除此區段 *@ @section Scripts { } @{ Layout = "~/_SiteLayout.cshtml"; Page.Title = "忘記您的密碼"; bool passwordSent = false; var resetToken = ""; var email = Request.Form["email"] ?? Request.QueryString["email"]; // 設定驗證 Validation.RequireField("email", "電子郵件地址欄位為必填。"); if (IsPost) { AntiForgery.Validate(); // 驗證電子郵件 bool isValid = true; if (Validation.IsValid()) { if (WebSecurity.GetUserId(email) > -1 && WebSecurity.IsConfirmed(email)) { resetToken = WebSecurity.GeneratePasswordResetToken(email); // (選擇性)為語彙基元指定到期日期 } else { passwordSent = true; // 我們不想透露使用者不存在。 isValid = false; } } if (isValid) { var hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped); var resetUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/PasswordReset?resetToken=" + HttpUtility.UrlEncode(resetToken)); WebMail.Send( to: email, subject: "請重設您的密碼", body: "使用此密碼重設語彙基元來重設您的密碼。語彙基元為:" + resetToken + @"。造訪 " + resetUrl + " 以重設您的密碼。" ); passwordSent = true; } } }

@Page.Title.

使用下列表格來重設您的密碼。

@if (!WebMail.SmtpServer.IsEmpty()) {

我們會將密碼重設指示傳送至與您的帳號關聯的電子郵件地址。

if (passwordSent) {

密碼重設指示已經傳送至指定的電子郵件地址。

}
@AntiForgery.GetHtml() @Html.ValidationSummary(excludeFieldErrors: true)
密碼重設指示表單

} else {

已停用此網站的密碼復原,因為 SMTP 伺服器 未正確設定。請連絡網站的擁有者以重設 您密碼。

}