0

I am trying to implement the idea found here in order "To facilitate multi-tab session states"

The shared solution speaks of Web Forms and wondering if it is possible to get a unique id for each new tab in asp.net MVC in order to use for each instance of session variables.

Community
  • 1
  • 1
usefulBee
  • 9,250
  • 10
  • 51
  • 89

1 Answers1

2

You won't be able to reliably check if a user has closed a tab in MVC due to the nature of restful Http requests.

If it's absolutely essential to keep track of open tabs I would think about SignalR, you can reliably track open tabs in real time using that. You would have to implement a collection of unique session objects synced to a unique ID on the matching tab. On submitting the form you would match the session by ID to the ID passed in by the form.

Having said that I would be very cautious about keeping anything specific to a certain page/tab in a session. It can lead to many confusing bugs that are very hard to debug, often leading to complete reworks.

Wurd
  • 465
  • 2
  • 15