472,117 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,117 software developers and data experts.

Page Reload After Back Button - Submit Form Twice - Please Help

Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how to

rectify or fix it??
Any help would be greatly appreciated.
Here is the c# code for the page load and also the code for the submit
button:
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["Complete"] == null || Session["Complete"].ToString()
!="complete")
{
Response.Redirect(NormUrl);

}
if(!Page.IsPostBack)
{

bttnContinue.ImageUrl = "Images/Bttn_Continu.gif";
ctrlAddress.PopulateDD();
ctrlAddress.PopulateY();
ctrlAddress.PopulateM();
ctrlAddress.PopulateT();
}
else
{
if(Session["_ViewState"] == null)
{
ctrlAddress.PopulateDD();
ctrlAddress.PopulateY();
ctrlAddress.PopulateM();
ctrlAddress.PopulateT();
}
}
}
private void bttnContinue_Click(object sender,
System.Web.UI.ImageClickEventA*rgs e)
{
string str1Complete = "complete";

ClearErrors();
ctrlAddress.ReadFields();
ctrlAddress.ClearErrors();
bool bOk = ctrlAddress.ValidateFields();
bool bOk1 = ctrlAddress.ValidateAmountYear*s();
if(bOk == true && bOk1 == true)
{
ctrlAddress.CreateSessionVaria*bles();
Session["1Complete"] = str1Complete;
Response.Redirect("2.aspx");
}
if(bOk == true && bOk1 == false)
{
ctrlAddressDetails.CreateSessi*onVariables();
Session["1Complete"] = str1Complete;
Response.Redirect("1a.aspx");
}
else
divOrderError.InnerHtml = "Blah.";
divOrderError2.InnerHtml = "blah.";
return;

Nov 17 '05 #1
2 3707
Frawls wrote:
Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
What is the "continue" button?
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page
just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how
to

rectify or fix it??


I'm not sure I understand your problem, but to me it seems as though
you've just discovered redirect-after-post. What happens is that in the
browser history, only the final request/response of a redirect chain is
saved.
In your case, it looks like this:
POST /p1.aspx --> 302 Found Location: /p2.aspx
GET /p2.aspx --> 200 OK

The browser only saves the last GET in its history. Thus, the POST is
never resubmitted by the browser when pressing refresh or back, which
is the reason why this pattern is actually quite useful ;-)

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2
Frawls wrote:
Hi
Can any one give me some help with this problem please?
Here is the scenario:
A user submits page 1 which is a web form.
After the form has been submitted they are (redirected) onto the next
page, page 2.
The user then clicks back on the browser.
They are now back in page 1
If the user clicks the continue button on page 1 this time the page
just reloads and the user has to click submit again to get to page 2.
What is the "continue" button?
In other words after clicking the back button the user has to submit
the form twice. (the first time it does not get submitted the page
just

reloads)
Is this a known issue? Can anyone tell me what is causing it and how
to

rectify or fix it??


I'm not sure I understand your problem, but to me it seems as though
you've just discovered redirect-after-post. What happens is that in the
browser history, only the final request/response of a redirect chain is
saved.
In your case, it looks like this:
POST /p1.aspx --> 302 Found Location: /p2.aspx
GET /p2.aspx --> 200 OK

The browser only saves the last GET in its history. Thus, the POST is
never resubmitted by the browser when pressing refresh or back, which
is the reason why this pattern is actually quite useful ;-)

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by | last post: by
6 posts views Thread by iwearwatches | last post: by
2 posts views Thread by John Lau | last post: by
6 posts views Thread by scottyman | last post: by
7 posts views Thread by Schmidty | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.