Software and Technology Ramblings

November 26, 2008


Filed under: Coding — Doug Hays @ 11:02 pm

In doing some research on ASP.NET MVC, Phil Haack mentioned a pattern that I had never heard of but love to use: PRG -or- Post, Redirect, Get.

Take a web form for example.  When the user clicks Save, the data is sent via POST back to the web application.  The web app saves the data to the database and then redirects the user to the next page within the application.  The user’s browser then requests that page via GET.  

The beauty of this pattern is made very clear by Phil.  This will eliminate the possibly confusing “Are you sure you want to resubmit this form data?” browser message.  But, for me, an even better reason is that it eliminates possible data issues when the browser re-posts the data after that refresh.  

Either way, I’m glad to have learned the name of this pattern and even more thankful that my use of it has been validated.

Powered by WordPress