0

I am facing a problem of mixed information between sessions in my application. The problem occurs when a user loads a page and it populates a session (Session ["Whatever"]) ... so far so good. The problem starts to happen when that same user opens the same screen on another browser tab for example. He carries other information for the same session that is used on the first screen it opened. (Here is a small example)

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
         if (Request.QueryString["id"] != null)
         {
             if (Request.QueryString["id"] != "")
                 Session["Any"] = Request.QueryString["id"].ToString(); //<-Here it changes the session for the first tab
         }
    }
}

I wonder if there is a better way to do this. Has some way to create a unique identifier for each tab opened by the user? Or some unique id in order to concatenate the name of the session? So sessions would be only by open flap.

Thanked.

Igor
  • 3,573
  • 4
  • 33
  • 55
  • 1
    There's not an easy way of uniquely identifying each tab. But I suggest you use ViewState instead of Session for things that are specific to one instance of a webpage. – mason Feb 28 '14 at 14:31
  • 1
    Check out this [question](http://stackoverflow.com/questions/2840615/asp-net-session-multiple-browser-tabs-different-sessions) – Damon Feb 28 '14 at 14:32
  • Thanks for the reply. Could you give me an example using ViewState? It is only by changing the Session ViewState - Hugs – Igor Feb 28 '14 at 14:33

0 Answers0