Click here to Skip to main content
16,016,088 members
Home / Discussions / C#
   

C#

 
QuestionC# Browser Back Button recognition. Pin
imnotso#27-May-08 0:35
imnotso#27-May-08 0:35 
AnswerRe: C# Browser Back Button recognition. Pin
leppie27-May-08 1:35
leppie27-May-08 1:35 
GeneralRe: C# Browser Back Button recognition. Pin
imnotso#27-May-08 1:43
imnotso#27-May-08 1:43 
GeneralRe: C# Browser Back Button recognition. Pin
leppie27-May-08 1:51
leppie27-May-08 1:51 
GeneralRe: C# Browser Back Button recognition. Pin
imnotso#27-May-08 2:19
imnotso#27-May-08 2:19 
AnswerRe: C# Browser Back Button recognition. Pin
GuyThiebaut27-May-08 2:31
professionalGuyThiebaut27-May-08 2:31 
GeneralRe: C# Browser Back Button recognition. Pin
imnotso#27-May-08 2:34
imnotso#27-May-08 2:34 
AnswerRe: C# Browser Back Button recognition. Pin
The Nightcoder27-May-08 13:16
The Nightcoder27-May-08 13:16 
One way of ensuring that the form isn't handled more than once (an order form for example) is:

1. On the page that renders the form for the user to fill in: Set a session variable (named so that it doesn't conflict with other forms/pages) to 1.

2. On the page accepting the post (may be the same page, but method=POST): If the session variable isn't 1, reject the post (show an error message or do something completely different). Otherwise, if the form data is valid and processing succeeds, set the variable to 2. If not, display the form again (again setting the variable to 1), preferably amended with an error message.

This way you won't accept the same form twice. If you don't want to use session variables (if you're on a server farm, for example), use your database instead. For example, create a row with a unique key (Guid/uniqueidentifier is good, but if security is important, add a signature) when the form is first created and include the key (and the signature if you have one) in the form as a hidden field. You then track transaction progress with another field in the record.

This can be elaborated to cater for multi-step transactions as well (including call-backs from, say, credit card payment servers) - but this should give you the general principle. Remember that you should also handle the case when someone jumps right into the middle of your app - and that this may very well be a hacker, faking the entire form contents, the referer field and pretty much everything else (hence the signature idea).

And like another poster noted - welcome to the world of web development - statelessness sucks!

Peter the small turnip

(1) It Has To Work. --RFC 1925[^]

AnswerRe: C# Browser Back Button recognition. Pin
neelchauhan28-May-08 2:22
neelchauhan28-May-08 2:22 
GeneralRe: C# Browser Back Button recognition. Pin
imnotso#28-May-08 2:46
imnotso#28-May-08 2:46 
QuestionThread abortion before closing form Pin
DeepOceans27-May-08 0:34
DeepOceans27-May-08 0:34 
AnswerRe: Thread abortion before closing form Pin
leppie27-May-08 1:37
leppie27-May-08 1:37 
GeneralRe: Thread abortion before closing form Pin
DeepOceans28-May-08 1:46
DeepOceans28-May-08 1:46 
GeneralRe: Thread abortion before closing form Pin
leppie28-May-08 5:55
leppie28-May-08 5:55 
GeneralRe: Thread abortion before closing form Pin
DeepOceans29-May-08 0:26
DeepOceans29-May-08 0:26 
Questionlog4net FileAppender -> Logging to File Pin
stephan_00727-May-08 0:24
stephan_00727-May-08 0:24 
AnswerRe: log4net FileAppender -> Logging to File Pin
buchstaben27-May-08 1:23
buchstaben27-May-08 1:23 
GeneralRe: log4net FileAppender -> Logging to File Pin
stephan_00727-May-08 3:27
stephan_00727-May-08 3:27 
QuestionThreading Common class Pin
kc_krishnan26-May-08 23:46
kc_krishnan26-May-08 23:46 
Questiongetting a data from a database and put in a xml document Pin
laziale26-May-08 23:19
laziale26-May-08 23:19 
AnswerRe: getting a data from a database and put in a xml document Pin
Giorgi Dalakishvili26-May-08 23:26
mentorGiorgi Dalakishvili26-May-08 23:26 
GeneralRe: getting a data from a database and put in a xml document Pin
laziale26-May-08 23:37
laziale26-May-08 23:37 
AnswerRe: getting a data from a database and put in a xml document Pin
Ashfield26-May-08 23:33
Ashfield26-May-08 23:33 
GeneralRe: getting a data from a database and put in a xml document Pin
laziale26-May-08 23:38
laziale26-May-08 23:38 
GeneralRe: getting a data from a database and put in a xml document Pin
Ashfield26-May-08 23:54
Ashfield26-May-08 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.