I have an ASP.Net questionnaire application that resubmits data to the same page, showing a different question each time. There are BACK and NEXT buttons to navigate between questions.
I would like to detect when the form is submitted due to a browser refresh vs. one of the buttons being pressed. I came across a WebForms approach but don’t know how to apply those principals in an MVC 2 application since page events aren’t available (as far as I know… I’m pretty new to Microsoft’s MVC model).
How would one apply that principle to MVC 2? Is there a better way to detect refresh?
You could use the redirect-after-post pattern with
TempData. Example:TempDataand redirects to another controller action which will verify that the data is inTempDataand return the viewTempDatayou know the user pressed F5 and didn’t pass through the form submission.And to illustrate this: