Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I created one login page. I want to send hashed password from view to controllers action by viewmodel.

login.cshtml code
C#
<div>
                @using (Html.BeginForm("UserLogin", "Login", new { FeatureName = "Login" }))
                {
                     @Html.AntiForgeryToken()
                 
                   <div class="login_box_container">
                        <div class="login_sections">
                            <div class="login_font">
                                @Html.LabelFor(model => model.UserName)
                            </div>
                            <div class="login_font">
                                @Html.TextBoxFor(model => model.UserName, new { @class = "login_textbox", @id = "txt_userId" })
                                 
                            </div>
                         </div>
                        <div class="login_sections">
                            <div class="login_font">
                                  @Html.LabelFor(model => model.HashedPassword)
                            </div>
                            <div class="login_font">
                                  @Html.PasswordFor(model => model.HashedPassword, new { @class = "login_textbox", @id = "txt_password" })   
                                  
                            </div>
                        </div>
                   
                   </div>                  
                             
                    <div class="login_button_container">

                            <div class="login_remenberme">
                                <input type="checkbox" />Remember me
                            </div>
                            
                            <input type="submit" value="UserLogin" class="login_button" />
                            @Html.ValidationSummary()
                    </div>
                }                    
             </div>

LoginController code
C#
[HttpPost]
public ActionResult UserLogin(LoginViewModel model, string FeatureName)
{
//some code here
}

What i want is model has hashedpassword property, but actually it is not hashed one, it is original string.

I want to send hashed password from view to controller, how can I achieve that?

Thank you in advance.
Posted
Updated 22-Aug-13 20:35pm
v3
Comments
Jameel VM 23-Aug-13 4:41am    
why u are hashing password from view itself? send the original string to server from there hash it and compared with hashed password in the db
ashok yede201 23-Aug-13 5:30am    
but, is it right to send original password from client to server?
I think it is insecure.
Jameel VM 23-Aug-13 6:45am    
it's not insecure.You should send the password as httppost request.Don't send it as query string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900