Detection of page refresh / F5 key in ASP.NET MVC 2

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-28T14:08:57Z Indexed on 2010/05/28 14:12 UTC
Read the original article Hit count: 451

Filed under:
|
|
|
|

How would one go about detecting a page refresh / F5 key push on the controller handling the postback? I need to distinguish between the user pressing one of two buttons (e.g., Next, Previous) and when the F5 / page refresh occurs.

My scenario is a single wizard page that has different content shown between each invocation of the user pressing the "Next" or "Previous" buttons. The error that I am running into is when the user refreshes the page / presses the F5 key, the browser re-sends the request back to the controller, which is handled as a post-back and the FormCollection type is used to look for the "submitButton" key and obtain its value (e.g., "Next," "Send"). This part was modeled after the post by Dylan Beattie at http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework.

Maybe I'm trying to bend MVC 2 to where it isn't meant to go but I'd like to stay with the current design in that the underlying database drives the content and order of what is shown. This allows us to add new content into the database without modifying the code the displays the content.

Thanks, Michael

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about postback