0

Im going to implment password reset functionality. First user enters email into the form. Then click submit. On the server side I check if the email is correct and if the user exists in database and if so then I redirect to the next page (in fact it is the same page with questry string parameter ?step=2).

I cant use session because of loadBalancer. What is the best way to keep users mail ?

thanks for any help

4
  • 1
    You have the email on the Database,don't you? Commented Aug 9, 2011 at 10:12
  • You could use database-backed session state. But why redirect? Can't you just use transfer to render the page there and then when you still have the email address to write to the page? Commented Aug 9, 2011 at 10:13
  • I dont understand, what does it meant to use transfer ? Commented Aug 9, 2011 at 10:23
  • Server.Transfer lets you switch the page you're rendering on the server. Commented Aug 9, 2011 at 17:11

3 Answers 3

1

If it is the same page then it should be fairly trivial. You could add a hidden input field and append it to your form so in your button click handler:

protected void Button1_Click(object sender, EventArgs e)
{
    string email = email.Text;
    //Check database etc

    HtmlInputHidden hidden = new HtmlInputHidden();
    hidden.Value = email;
    hidden.ID = "hiddenemail";
    form1.Controls.Add(hidden); // Where form1 is the ID of a form with runat=server
}

Or event better if there was an existing server control say a label that you could use you would just do:

protected void Button1_Click(object sender, EventArgs e)
{
    string email = email.Text;
    //Check database etc
   Label1.Text = email; // Where Label1 is the ID of a ASP:Label on your page
}
Sign up to request clarification or add additional context in comments.

1 Comment

Actually disregard my answer, I obviously didn't read your question properly
1

If you do not want to use a Postback (for whatever reason) and cannot use Session, the only solution I see is to include the email in the querystring.

Response.Redirect("MyPage.aspx?step=2&email=" + Server.UrlEncode(emailaddr));

If it does not necessarily have to be a redirect, see James Hay's answer.

Comments

0

I honestly don't understand the issue here?

If you have the email in the Database that must mean you also have all the other information in the Database. So to skip all the reload page etc. then go ahead and use <asp:Panels> or <asp:Views> as the swap between visible=false/true have no requirement for a page-reloading postback.

Example

if(email == emailFromDB)
{
    panelStep1.visible=false;
    panelStep2.visible=true;

    // Insert information into whatever controls you have in mind.
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.