@{
Layout = "~/Shared/Layouts/_Layout.cshtml";
Page.Title = "Forgotten Password";
var email = "";
var message = "";
if(IsPost)
{
email = Request["email"];
// Validation
if (email.IsEmpty()) {
ModelState.AddError("email", "Email Address is required.");
}
// Generate and send password reset email
if(ModelState.IsValid)
{
if(WebSecurity.UserExists(email))
{
// Generate confirmation link URL
var resetToken = WebSecurity.GeneratePasswordResetToken(email);
var hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer,
UriFormat.Unescaped);
var passwordResetUrl = hostUrl +
"/Account/PasswordReset?resetToken=" +
HttpUtility.UrlEncode(resetToken);
// Send email
WebMail.Send(to: email,
subject: "MyEshop Password Reset for " + email,
body: "Please visit <a href='" + passwordResetUrl + "'>" +
passwordResetUrl +
"</a> to reset your MyEshop account password."
);
message = "An email has been sent to your registered email address " +
"with a password reset link and further instructions.";
}
else
{
message = "Unable to find matching account.";
}
}
}
}
<h2>Restore your password</h2>

@if (!message.IsEmpty()) {
    <p>@message</p>
}

else {
    <div class="form">
        <form action="ForgottenPassword" method="post" class="accountForm">
        <p>Enter your e-mail address to reset your password</p>
        <div><p>
        <span class="formtitle">@Html.Label("Email Address: ", "email")</span>
        @Html.TextBox("email", email)
        @Html.ValidationMessage("email")
        </p></div>
        <p>
        <input type="submit" value="Reset Password" />
        </p>
        </form>
    </div>
}