2016-11-04 5 views
0

私は自分のプロジェクトにパスワードリセット機能を持っています。トークンを使用してユーザーにリンクを送信しています。彼らがリンクをクリックした後、私はHomeControllerの中に入り、ResetPasswordメソッドを呼び出す必要があります。私の問題は、私がどこに置いても、私がログインページを開いたときに、ResetPasswordパーシャルビュー(それはモーダル)をどこに置かなければならないのかわからないということです。彼らはそれをクリックしたときに、私はこの方法に行く必要がパーシャルビューはどこに置くべきですか

http://...myurlaction=resetpassword&userid=5&[email protected]&token=1234564

は、最初の方法を取得するようになった:

[HttpGet] 
[Route("resetpassword")] 
[AllowAnonymous] 
public ActionResult ResetPassword(ResetPasswordRequest resetPasswordRequest) 
{ 
    //check if Token is valid show the view 
    return PartialView(); 
} 

は、ユーザーの電子メールでこのリンクを考えます投稿後、POSTメソッド:

[HttpPost] 
[Route("resetpassword")] 
public ActionResult ResetPassword(ResetPasswordView resetPasswordView) 
{ 
    return PartialView(); 
} 

、これは部分図である。

<div id="myModal" class="modal"> 
<div class="modal-content"> 
    <span class="close">x</span> 
    @using (Html.BeginForm("resetpassword", "Home", FormMethod.Post)) 
    { 
     <h5>Reset Your Loan Center Password</h5> 
     <table> 
      <tr><td>Email Address</td><td><input type="email" name="Email" placeholder="[email protected]"></td></tr> 
      <tr><td>Password</td><td><input type="Password" name="Password" placeholder="Create Password"></td></tr> 
      <tr><td>Confirm Password</td><td><input type="Password" name="ConfirmPassword" placeholder="Re-enter Password"></td></tr> 
      <tr><td colspan="2"><input type="submit" value="Reset Password"></td></tr> 
      <tr> 
       <td class="errMessage" colspan="2"> 
        @Html.ValidationSummary(true) 
       </td> 
      </tr> 
     </table> 
    } 
</div> 

私の問題は、私はどこでも私はそれがあってもリセットパスワードビューを表示持っているので、@Html.Partial("Login") を持っている必要がどこかわからないということですIドンそれを示す必要はありません。

+0

あなたPOSTメソッドも必要です

[HttpGet] [Route("resetpassword")] [AllowAnonymous] public ActionResult ResetPassword(ResetPasswordRequest resetPasswordRequest) { //check if Token is valid show the view Viewbag["state"] = "ResetPassword"; return YourLoginPage(); } 
は '[のAllowAnonymous]' - ユーザーがまだ認可されていない –

+0

@Stephen Muecke(と彼らは同じシグネチャを持つべきではない)、事はそれは私の後にポストに進むですビューに値を入力しますが、それは取得に行くわけではありません。 – Alma

答えて

1

Loginページのコードを再利用するため、あなたの説明に基づいてPartialViewを使用していると思います。基本的に、Loginページには2つの状態があります.1つはログイン用で、もう1つはパスワードをリセットするためのものです。その後

@if (Viewbag["state"] == "Login") { 
    Html.RenderPartial("Login"); 
} else { 
    Html.RenderPartial("resetpassword"); 
} 

、あなたはこのように、LoginControllerResetPasswordControllerあなたにViewbagの適切な値を設定されている何をすべきか:活性化されている状態を知るために、あなたは、あなたのLoginページ内のようなものが旗を持っている必要があります:

0

あなたの質問を正しく理解していれば、あなたのホームコントローラからパーシャルを呼び出すときに、部分ビューがアプリケーションのViews \ Homeフォルダにあるはずです。あなたの家のコントローラにあるものよりも、パスワードが「アカウント」機能のほうがはるかに重要であるため、アクションメソッドをアカウントコントローラに移動することもできます。この場合、部分ビューはViews \ Accountに追加されます。

+0

私はどこに@ Html.Partial( "resetpassword") – Alma

関連する問題