As you know, HTTP is stateless, and the use of session variables is a very common mechanism for state between requests. The problem occurs when you open a new brower tab, because the session is the same, so any change you make on the new tab will affect the other tabs. You did not specify exactly what you want, but let me say that you have a product list page in which the user can enter search filters and you want to save them in the session. If the user sets the search filter value on tab 1, tab 2 will have the same value (they share the session variables). What can you do?
1) Use this approach to add a pointer to the URL: http://www.codeproject.com/Articles/331609/Get-an-unique-session-in-each-browser-tab
2) Do something similar to the one described in the previous paragraph, but not in the same way, and this is what I did to solve the same problem.
a) My links to the serach page is / Product / List? guid = xxx instead of just / Product / List. If the user manually creates / Product / List, I redirect it to the new URL where the GUID is set.
public ActionResult List(string guid) { if (guid == null) { return RedirectToAction("List", new { guid = Guid.NewGuid().ToString() }); } ...
Each time you click on the list link and configure a new tab, a new GUID is created.
b) I have a session key with a GUID, so each page has its own values. You can open 2 tabs at the same time, and they are going to use different session values, because guid will be different.
This solution is not perfect, but at least it works.
Hope this helps.
source share