多标签浏览器中的唯一会话 [英] Unique session in multitab browser

查看:106
本文介绍了多标签浏览器中的唯一会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在浏览器的多个标签中使用唯一的会话?
我做了研究,发现了这行代码

Hi,

how can i use unique sessions in a browser multiple tabs?
i''ve done research and found this line of code

<sessionState mode="InProc" cookieless="UseUri" />


我也使用了上面的代码,但效果不佳.我也有表单身份验证.
还有其他办法吗?

帮帮我.
预先感谢.


i used the above code also but its not working well. I have formsauthentication also.
are there any other way?

Help me for this.
Thanks in advance.

推荐答案

那将很难实现.它的浏览器功能.唯一可能的方法是,通过在页面上保留隐藏值并将其与每个请求一起发送以确保它用于同一会话,从而放置/保持选项卡的跟踪.

在此处详细了解更多信息:停止在浏览器的多个选项卡之间共享会话状态 [ ^ ]

最简单,可以的实现(检查缺点),可以尝试以下方法:
手动生成唯一的页面标识代码,并将其插入每页的隐藏字段中.
That would be difficult to achieve. It''s browser feature. Only possible way could be to place/keep track of a tab by keeping a hidden value on the page and sending that across with every request to make sure it is for the same session.

Read more about it here in detail: Stop Sharing Session State between Multiple Tabs of Browser[^]

Easiest and ok-ok implementation (keeping disadvantages in check), following can be tried:
Manually generate unique page identification code and insert it into hidden field on every page.
<asp:HiddenField ID="PageID" runat="server" />



在表单加载中包括以下代码.它将基于毫秒和其他时间分量生成唯一的页面标识代码,这些代码对于您的网站始终是唯一的.



In the form load include following code. It will generate unique page identification code based on millisecond and other time component which always be unique for your site.

If Not IsPostaback Then
  'Generate a new PageiD'
  Dim R As New Random(DateTime.Now.Millisecond +
         DateTime.Now.Second * 1000 +
         DateTime.Now.Minute * 60000 +
         DateTime.Now.Minute * 3600000)
  PageID.Value = R.Next()
End If



因此,通过这种方法,您可以将每个选项卡请求标识为唯一请求.但是它具有以下两个缺点.

第一:仅在回发时恢复ViewState时,才可以访问隐藏元素PageID.因此,您无法在page_init()中访问PageID.
第二:由于访问者可以访问隐藏字段,因此任何人都可以更改PageID.因此,该解决方案仅适用于所有用户的信任度为100%的环境.



更新:
使用Route的相同博客文章:在中获得唯一的会话每个浏览器标签 [ ^ ]



So by this method you can identify each tab request as unique requests. But it has following two disadvantages.

First: The access of hidden element PageID is only when ViewState is restored on postback. So you cannot access PageID in page_init().
Second: As hidden field is accessible to the visitor, anyone can change PageID. So this solution will work only for environment with 100% trust ratio of all user.



UPDATE:
A good blog entry for same using Route: Get an unique session in each browser tab[^]


这篇关于多标签浏览器中的唯一会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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