围绕ASP.NET会话方式正在多个标签窗口共享 [英] Way around ASP.NET session being shared across multiple tab windows

查看:119
本文介绍了围绕ASP.NET会话方式正在多个标签窗口共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我存储在第一页上一个asp.net会议上,一些价值。在接下来的页面,本次会议的价值正在被读取。但是,如果多个选项卡中打开,并有多个页面1->第2页导航回事,存储在会话中的值将被从会话中的浏览器标签页之间共享混合起来。

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 multiple page 1->page 2 navigation going on, the value stored in session gets mixed up since the session is shared between the browser tabs.

我不知道什么是解决这个问题的选项:

I'm wondering what are the options around this :

  1. 查询字符串:使用查询字符串的页面之间传递的价值,我也不想采取这种方法,因为有可能是第1页上的多个锚标签链接到第2页,我不能改写的每个网址标签,因为它们是动态的。

  1. Query String: Passing value between the pages using query string, I don't want to take this approach since there can be multiple anchor tags on page 1 linking to page 2 and I can not rewrite the URLs of each tag since they are dynamic.

饼干???在内存中的cookie跨浏览器标签页共​​享也一样会话cookie,仪式?

Cookies??? In-memory cookies are shared across browser tabs too, same as the session cookie, rite ?

任何其他的选择吗?

PS:第1页第2页是不是表单提交

PS: Page 1 to page 2 is not a form submit.

推荐答案

我想出了一个解决办法:

I figured out a solution :

  1. 使用JavaScript分配一个唯一的ID就像一个GUID到浏览器窗口/标签按指定的GUID值到 window.name 属性。 window.name属性是唯一的每个浏览器窗口/标签并不会隔着玻璃窗共享。

  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.

使用GUID为重点,读取并通过web服务数据写入到ASP.NET会话。由于JavaScript没有访问asp.net会议上,您将需要使用一个Web服务,并调用它的通过JavaScript的方法。

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.

中的数据可以JavaScript和Web服务之间通过JSON被转移。

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

干杯!

这篇关于围绕ASP.NET会话方式正在多个标签窗口共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆