Uniquely identify two instances of the same browser sharing session state?

I want the user not to edit the same form data in two different tabs or browser windows (of the same web browser instance). The goal is to prevent the user from accidentally rewriting their data, as they continue in a very long form. On the server, the current data entered through the screens is collected in a session.

Suppose that for any browser, all tabs and windows are executed in one instance (i.e. not every one in a separate process). Obviously, browser tabs and windows share the same cookies in this scenario, so modifying cookies cannot be resolved due to viable solutions. This is also the reason that they use the same session state.

Given that the form has already been created, and this is one of the final touches, how can I easily use ASP.NET to observe this β€œFeature”?

+4
source share
6 answers

You can try something like this:

Save the integer as Session ["LastRequest"]. Put this in a hidden box on the page. For each request, you add one to the whole.

In the reverse order, make sure no other request has been made by checking that Request.Form ["LastRequest"] is equal to Session ["LastRequest"].

If you need to check multiple instances before the postback occurs, you can do this with AJAX calls.

+3
source

Each time you render a form, set the value of some hidden field to a random line. Keep the same row in session state. When the user sends messages back, check if these two values ​​are equal. If not, this should be a repeated post.

+2
source

You cannot distinguish two http POSTs for the same page, even if they are from different tabs.

This looks like a known problem with the back buttons - they can post, wring and repon.

Hidden tracking fields are a common solution, but it is very difficult to make them reliable.

If it is a wizard-type process, it should be easy to detect if they are rewriting fields that have already been entered and show a warning.

+1
source

When rendering the specified page, create a GUID and save the session. Write a generic handler that tracks that there are no two GUIDs for the specified page.

This data structure will help.

class MultipleOpenedPage{ string guid; string pageURL; DateTime timeStamp; bool IsMultiplePageOpened(List<MultipleOpenedPage> list) { ///logic } } 
0
source

Due to the statelessness of the network, I do not believe that there is a reliable way to distinguish between two browser windows. However, you can save the flag in a session that performs this lengthy process. Thus, you don’t care if they try to restart the process from one browser window or several browser windows. The trick will handle situations where the process crashes and has no chance of resetting the flag so that this process can be started again.

0
source

I got around this by creating a base class that inherits from System.Web.UI.Page and in the page_load / init event, creating an object containing information specific to the user instance.

It was every new page that created its own instance of the object and therefore could support different states / properties that can be used to make individual changes to the data on one page.

Just the thought that is a little different.

0
source

Source: https://habr.com/ru/post/1304083/


All Articles