Shaver: hidden password control (registration 2 pages)

I am creating a two page razor registration process. The difficulty here is to collect data (username, password, etc.) on the first page and use hidden input variables to store data on the first page on the second.

here is my hidden code:

<div id="hidden vals" style="display:none;"> @Html.HiddenFor(model => model.userRegisterModel.UserName) @Html.HiddenFor(model => model.userRegisterModel.studentFirstName) @Html.HiddenFor(model => model.userRegisterModel.studentlastName) @Html.HiddenFor(model => model.userRegisterModel.Email) @Html.PasswordFor(model => model.userRegisterModel.Password) @Html.PasswordFor(model => model.userRegisterModel.ConfirmPassword) </div> 

the problem is the password and password confirmation. I do not want to use a hidden password type field, but I want my password to be saved, but not displayed in the page source. but "PasswordFor" has a side issue that it "depopulates" the values ​​and causes the user to re-populate.

So, to reinstall, I need my password and confirm that it is saved and preferably not displayed to the user. Urine is important, I need my password and confirm the values ​​not hidden from the "view source"

My alternative strategy is to use a session variable to store all the values ​​of "page 1", but this eliminates another disadvantage of id.

+4
source share
2 answers

Can a different approach be proposed? Instead of two-page use two-div.

You can still use features such as validation (client and remote) and make sure that the user cannot go without a valid form. If there is something that needs to be loaded and / or created for the second page, you can do it with Ajax, and your form can still live on the page without using hidden fields or session / timeout variables.

 <form ...> <div id="part-one"> <!-- content... --> </div> <div id="part-two" style="display:none;"> <!-- content... --> </div> <div> <button type="button" id="prev-div">Previous</button> <button type="button" id="next-div">Next</button> <button disabled="disabled" id="next-div">Submit</button> </div> </form> 

The buttons remain visible, you can switch their state using jQuery, and if your requirements change the update for your model class and view, that’s all that is required (if you use model binding).

+2
source

Yes. Store them in a session and access it in the second page / action method.

And Be sure to clear this particular session variable after you read it to maintain persistent storage.

+1
source

Source: https://habr.com/ru/post/1434204/


All Articles