views:

215

answers:

1

Hi guys, i have a form which allows the user to key in the data and then submit. if everything works well on this action result, then i will redirect the user back to a thank you page.

my problem right now is that when the user click on the back button, they will be able to go back to the form page and the inputs will still be there.

and if the user just click on submit again, i will be getting some potential weird bugs.

so in terms of asp.net mvc, what's the best way to handle users who click on the back button?

thanks!

+1  A: 

What do you mean by "potential weird bugs"? I doubt the user would click submit again unless they wanted to post exactly the same thing again. I you don't want duplicate posts, check the content against your DB before posting.

If you really don't want people posting the same form twice, put a randomly generated number (just make sure it's random enough to avoid collisions, or use something like a combination of the user ID and a precise timestamp) into a hidden field, save that with your data and check that it doesn't already exist in your DB before saving anything.

Matti Virkkunen
Since asp.net mvc is stateless I was just thinking maybe they have a new shebang method or best practice to handle this too.
melaos
I don't like when people claim some method is "the best practice".
Matti Virkkunen
lol true, but there's ugly hacks and then there's better tried and tested alternatives to use. i try to avoid the former as much as possible.
melaos