I want to ensure a user isn’t editing the same form data in two different browser tabs or windows (of the same web browser instance). The intention is to stop the user from accidentally overwriting their own data as they continue through a very long form process. On the server, ongoing data input through the screens is collected into the Session.
Assume for any browser, all tabs and windows run in the same instance of it (i.e. not each in a separate process). Obviously the browser tabs and windows share the same cookies in this scenario so cookie modification seems out of the question for viable solutions. This is also the reason they are sharing the same session state.
Considering that the form is already created and this is one of the final touches, how can I use ASP.NET, hopefully easily, to oversee this
“feature”?
You could try something like this:
Store an integer as Session[“LastRequest”]. Put this into a hidden field on the page. For every request, you add one to the integer.
On postback, make sure that no other request has been made by checking that Request.Form[“LastRequest”] is equal to Session[“LastRequest”].
If you need to check for multiple instances before the postback happens you should be able to do so using AJAX calls.