简体   繁体   中英

C# CompareValidator, Using Session to get ControlToCompare from Previous Page

I have two pages. The first page is a registration page where the user creates a user name and password. The second page is a log in page, where the user enters their user name and password. I want to use CompareValidator to make sure the user name and password match the credentials that they created. I thought that I could call the TextBox from the registration page, in my ControlToCompare:

//TextBoxLogIn is from the first page
<asp:CompareValidator ID="CompareValidatorUserName" runat="server" ErrorMessage="Wrong User Name" ForeColor="Red" ControlToCompare="TextBoxLogIn" ControlToValidate="TextBoxUserName"></asp:CompareValidator>

I can't seem to be able to find anything on this specific issue. Does anyone have any suggestions on how this can be done?

This is a classic behaviour of http - it is stateless ie, once response is sent, the transaction is complete and gone.

It is the server or the client(your browser) which has to keep the track of data.

So to access page 1's data from page 2, first store page 1's data somewhere - either the browser's cache or server's session variable.

BUT

I would never store passwords anywhere other than LDAP servers - even there the passwords are encrypted and then stored.

Browser: Local Storage vs Cookies

Server: https://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM