locked
Session overlapping issue RRS feed

  • Question

  • User-1804077972 posted

    Hi,

    I am working on mvc5. The issue I am facing is if I open my website in multiple tab or browser session is getting overlapped.

    For eg: if I login into my account and create a business profile and proceed with that, after some time I open the site in different tab or window(same logged in account) and create one more business profile, that time first business profile session value is getting exchanged/overlapped with second business profile session value. So at the end I have second business profile value in session in both the tabs or browser. I am using three important session which I cannot ignore, if user plays around like this by opening in multiple tab or window or browser session is getting changed.

    Any suggestion how to resolve this issue?

    Thursday, August 25, 2016 12:28 PM

All replies

  • User765422875 posted

    MVC is structured around the idea that your website is a view into a logical model of information. It encourages having stateless operations through the use of simple controllers responding to actions with key information passed as part of the HTTP request. Because of this, session is no longer required to perform basic tasks in MVC and becomes poor fit where it seemed a perfectly valid choice before.

     That being said, perhaps you have a few options:

     1)     Prevent the user from opening a new tab for your application. For this search google for "preventing multi-tab browsing of asp.net application". There are a number of ways, one which is good is using JavaScript which uses window name.

    2)     Enable cookieless session. This will make your URL look ugly but will let you use multiple tabs for different users without any clash of session ids.

    3)     Use a token in the URL parameter. See the following solution:

             http://www.codeproject.com/Questions/616892/Session-Overlapping-in-different-Tabs-on-a-same-br

    4)     Look into some of the MVC alternatives to session. More details here:

             http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications/

    Thursday, August 25, 2016 4:46 PM