views:

378

answers:

4

Probably not but i want to ask. Will redirect avoid double posting? I know there are better ways to avoid it but how do most double post happen? from my understanding its when the current page doesnt load and the user hits refresh, not bc of clicking post multiple times. I figure redirect info are so small that when the user hits refresh it will just try to load the new page and not resent the POST data.

Its just a very easy and fast solution, i just wanted to know if its highly effective or not?

A: 

I think that approach works in most success cases. For failures, it gets a bit ugly.

leppie
A: 

Yes, it works for that purpose.

Jacob
+1  A: 

It's a good thing to avoid accidental double posting.

It's even a best practice, and many MVC frameworks provide easy ways to do it.

It also prevents users being annoyed because they can't refresh a page without resending data.

FWH
+5  A: 

Yes, redirecting to avoid double posting is so common and so effective that the technique has a name, "Post-Redirect-Get." It will also make your ASP.NET code cleaner, since your pages won't need to handle both gets and posts. No more of this:

if (!this.IsPostBack) {
    // Do one thing for gets
} else {
    // Do something else for posts
}

The only drawback is that it can complicate the display of status and error messages.

Jeff Sternal