I have an index page that sends users to the product editing page in separate browser tabs.
For each edited product, the index overwrites the session ["ProductID"].
Then on the "Edit" page there is the following code for the unique identifier of this tab and product:
if (!IsPostBack) //first time page load { Random R = new Random(DateTime.Now.Millisecond + DateTime.Now.Second * 1000 + DateTime.Now.Minute * 60000 + DateTime.Now.Minute * 3600000); PageID.Value = R.Next().ToString(); Session[PageID.Value + "ProductID"] = Session["ProductID"]; }
This works, and when the same user opens several tabs, I only refer to Session [PageID.Value + "ProductID"] in my code so that I always have the correct identifier. (I work in a reliable environment, this is for the intranet, so I'm not too concerned about the level of security).
My problem arises if the user refreshes the page by pressing F5. At this point, the [PageID.Value + "ProductID"] session receives the ["ProductID"] session of the last product that it opened.
For instance:
User 1 opens product1 in tab1
User 1 opens product2 in tab2
Whenever they usually use the tool, everything works fine. However, if:
User 1 on page product1 gets to the update button (F5), page product1 becomes page product2
Is there a way to detect a page refresh from the “first load / redirect from another page” so that I can then tell my page that it is not updating my session [PageID.Value + "ProductID"]?
source share