Way around ASP.NET session being shared across multiple tab windows

后端 未结 6 680
半阙折子戏
半阙折子戏 2020-12-09 17:17

I\'m storing some value in an asp.net session on the first page. On the next page, this session value is being read. However if multiple tabs are opened and there are multip

6条回答
  •  执念已碎
    2020-12-09 18:14

    I figured out a solution :

    1. Using Javascript assign a unique id like a guid to the browser window / tab by assigning the guid value to the window.name property. window.name property is unique to each browser window/tab and won't be shared across the windows.

    2. Using the guid as the key, read and write data to your ASP.NET session via a webservice. Since javascript does not have access to asp.net session, you will need to use a webservice and call it's method through javascript.

    The data can be transfered between javascript and webservice via JSON.

提交回复
热议问题