Posted by Doug Hays on the 26th of November, 2008 at 11:02 pm under Coding.    This post has 319 comments.

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.