Quantcast
Viewing all articles
Browse latest Browse all 31

Mike on ASP.NET MVC - Using Post, Redirect, Get Pattern

Woudn't this be easier?

1. HTTP GET of "/products/create", "Create" view is rendered
2. HTTP POST to "/products/submit"
3. Validation Fails, "Create" view is rendered with error message
4. HTTP POST to "/products/submit"
5. Item is created, redirect to "/products/confirm", "Confirm" view is rendered

This way you don't need to store anything in your temp data between create atempts and you don't get a repost on the confirm screen. A refresh at step 3 will only re-submit bad data, which will fail and they will get the create screen, so the only thing that could be lost is any data they have updated in the form before refreshing.

Viewing all articles
Browse latest Browse all 31

Trending Articles