2012-11-15 23 views
1

我有以下網頁:郵政調用錯誤的網頁

SecurityQuestion.cshtml

@model SuburbanCustPortal.Models.SecurityQuestionModel 

@{ 
    ViewBag.Title = "Forgot Password Step 2"; 
} 

<h2>Forgot Password Step 2</h2> 
<p> 
    Please provide the answer to your security question that you gave when you created your web account. 
</p> 

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 

@using (Html.BeginForm()) { 
    <div> 
     <fieldset> 
      <legend>Security Question and Answer</legend> 

      <!-- this is the question --> 
      <div class="editor-label"> 
       @Html.LabelFor(m => m.SecurityQuestion) 
      </div> 
      <div class="editor-field"> 
       @Html.TextBoxFor(m => m.SecurityQuestion, new { @class = "GenericTextBox", @readonly = "readonly" }) 
      </div> 

      <!-- this is the answer --> 
      <div class="editor-label"> 
       @Html.LabelFor(m => m.SecurityAnswer) 
      </div> 
      <div class="editor-field focus" > 

      @Html.TextBoxFor(m => m.SecurityAnswer, new { @class = "GenericTextBox" }) 
      @Html.ValidationMessageFor(m => m.SecurityAnswer) 
      </div> 
       @Html.ValidationSummary(true, "The supplied answer did not match the answer on the account.") 
      <p> 
      <input type="submit" value="Complete Step 2" /> 
      </p> 
     </fieldset> 
    </div> 
} 

ForgotPassword.cshtml

@model SuburbanCustPortal.Models.ForgotAccountInfoModel 

    @{ 
     ViewBag.Title = "Forgot Password Step 1"; 
    } 

    <h2>Forgot Password Step 1</h2> 
    <p> 
     Please provide the username or email address on your web account. 
    </p> 

    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 

    @using (Html.BeginForm()) { 
     <div> 
      <fieldset> 
       <legend>Email address</legend> 

       <div class="editor-label"> 
        @Html.LabelFor(m => m.UsernameOrEmail) 
       </div> 
       <div class="editor-field focus"> 
        @Html.TextBoxFor(m => m.UsernameOrEmail, new { @class = "GenericTextBox" }) 
        @Html.ValidationMessageFor(m => m.UsernameOrEmail) 
       </div> 
        @Html.ValidationSummary(true, "Username or Email address was not found.") 
       <p> 
       <input type="submit" value="Complete Step 1" /> 
       </p> 
       <br/> 
       <p align="right"> 
       Step 1 of 3 
       </p> 
      </fieldset> 
     </div> 
    } 

這是我的控制器:

public ActionResult SecurityQuestion() 
{ 
    return View(); 
} 

[HttpPost] 
public ActionResult SecurityQuestion(SecurityQuestionModel model) 
{ 
    const int maxnumberofattemptsallowed = 3; 

    if (model.SecurityAnswerAttempts > (maxnumberofattemptsallowed -1)) 
    { 
    var msg = 
     string.Format(
     "Max number of attempts allowed. Your account has been locked.{0}Please contact us for assistance in unlocking your account.", 
     "<br>"); 
    ModelState.AddModelError("SecurityAnswer", msg); 
    return View("LogOn"); 
    } 

    if (_client.ValidateSecurityAnswer(model.AccountId, model.SecurityAnswer)) 
    { 
    var msg = 
     string.Format(
     "The supplied answer did not match the answer on the account.{0}You have {1} more attempt(s) before your account is locked.", 
     "<br>", maxnumberofattemptsallowed - model.SecurityAnswerAttempts); 
    model.SecurityAnswerAttempts++; 
    ModelState.AddModelError("SecurityAnswer", msg);   
    return View(model); 
    } 

    // send email here 

    return View(model); 
} 

public ActionResult ForgotPassword() 
{ 
    return View(); 
} 

[HttpPost] 
public ActionResult ForgotPassword(ForgotAccountInfoModel model) 
{ 
    var tokenid = MiscClasses.TokenIdCookie.GetTokenIdCookie(); 

    var secdata = new SecurityData(); 
    secdata.EmailOrUsername = model.UsernameOrEmail; 
    secdata.TokenId = tokenid; 
    secdata = _client.ForgotPasswordGetSecurityQuestion(secdata); 
    if (!string.IsNullOrEmpty(secdata.SecurityQuestion)) 
    { 
    var newmodel = new SecurityQuestionModel(); 
    newmodel.SecurityQuestion = secdata.SecurityQuestion; 
    newmodel.SecurityAnswer = string.Empty; 
    newmodel.SecurityAnswerAttempts = 0; 
    newmodel.AccountId = secdata.AccountId; 
    return View("SecurityQuestion", newmodel); 
    } 
    { 
    ModelState.AddModelError("EmailAddressNotFound", "Email address not found."); 
    return View(model); 
    } 
} 

應該以下面的方式起作用:

的ActionResult ForgotPassword() - > ForgotPassword查看 - > [HttpPost]的ActionResult ForgotPassword(ForgotAccountInfoModel模型) - >的ActionResult SecurityQuestion() - > SecurityQuestion視圖 - >[HttpPost]

相反,它是這樣做的的ActionResult SecurityQuestion(SecurityQuestionModel模型):

的ActionResult ForgotPassword() - > ForgotPassword查看 - > [HttpPost]的ActionResult ForgotPassword(ForgotAccountInfoModel模型) - >的ActionResult SecurityQuestion() - > SecurityQuestion查看 - >[HttpPost]的ActionResult ForgotPassword(ForgotAccountInfoModel模型)

而對於我的生活我無法弄清楚爲什麼它正在重新加載ForgotPassword POST!

任何人看到我失蹤?

回答