Note that there are some explanatory texts on larger screens.

plurals
  1. POPage refresh Vs IsPostBack
    primarykey
    data
    text
    <p>I've got an index page which sends users to an edit products page on separate browser tabs.</p> <p>For each products edited the index rewrites the Session["ProductID"].</p> <p>The Edit page then has the following code to have a unique identifier for this tab and product:</p> <pre><code>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"]; } </code></pre> <p>This works, and when the same user opens multiple tabs I only reference the Session[PageID.Value + "ProductID"] in my code so that I always have the proper ID. (I'm working in a trusted environment this is for an intranet, therefore I'm not too bothered with the level of security).</p> <p>My issue occurs if the user does a page refresh by hitting the F5 key. At which point the Session[PageID.Value + "ProductID"] gets the Session["ProductID"] of the last product he opened.</p> <p>For example:</p> <p>User 1 opens product1 in tab1</p> <p>User 1 opens product2 in tab2</p> <p>Whenever they use the tool normally, everything works fine. However if:</p> <p>User 1 on product1 page hits the refresh button (F5) the product1 page becomes product2 page</p> <p>Is there a way to detect a page refresh from a "first load/redirect from another page" so that I can then tell my page not to update my Session[PageID.Value + "ProductID"]?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload