阻止两个浏览器选项卡共享相同的会话值 [英] Preventing two browser tabs to share the same sessions values

查看:62
本文介绍了阻止两个浏览器选项卡共享相同的会话值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:



我正在使用C#4.0在Asp.Net 4.0中开发一个应用程序。当用户使用登录应用程序时,让我们说一个浏览器选项卡,而另一个用户使用另一个选项卡登录到同一个应用程序,其中一个选项卡会立即将其内容(用户数据)更改为其他标签'。这是非常令人沮丧的,任何处理这个问题的帮助/解决方案都是欢迎。

I have the following problems:

I am developing an application in Asp.Net 4.0 under C# 4.0. When a user logs into the application using, let''s say a browser "tab" and another user logs into the same application using another ''tab'', one of the tabs will change immediately its content (users data) into the other tab''s. It is very frustrating and any help/ solution to handle this would be WELCOME.

推荐答案

虽然我无法弄清楚你的目的是什么,但请考虑以下几点: br />
- cookie链接到域,因此如果你使用基于cookie的身份验证和/或会话,你甚至不能在选项卡之间分离登录,甚至在浏览器实例之间也是如此(有一个例外:由于它是'目的,私人或隐身浏览器会话与正常浏览器会话完全分开。

- 因此,如果您希望能够在写入时分离登录,则必须禁用会话的cookie和身份验证,请参阅: http://msdn.microsoft.com/en-us/library/aa479314.aspx [ ^ ], http://msdn.microsoft.com/en-us/library/aa47 9315.aspx [ ^ ], http://www.asp.net/web-forms/videos/authentication/how-to-setup-and-use-cookie-less-authentication-in-an-aspnet-application [ ^ ]
Although I can''t figure out what your purpose is, consider followings:
- cookies are linked to domains, thus if you use cookie based authentication and/or session, you can not separate the logins between tabs not even between browser instances (with one exception: due to it''s purposes, "private" or "incognito" browser sessions are totally separated from the normal ones)
- thus if you want to be able to separate logins as you wrote, you have to disable cookies for session and authentication, see: http://msdn.microsoft.com/en-us/library/aa479314.aspx[^], http://msdn.microsoft.com/en-us/library/aa479315.aspx[^], http://www.asp.net/web-forms/videos/authentication/how-to-setup-and-use-cookie-less-authentication-in-an-aspnet-application[^]


您可以做两件事:



1)防止用户为您的应用程序打开一个新选项卡。对于此搜索谷歌防止多页面浏览asp.net应用程序。有很多方法,一个很好用的是使用javascript,它使用窗口名称。



2)启用无cookie会话。这会使您的网址看起来很丑,但会让您为不同的用户使用多个标签,而不会出现任何会话ID冲突。
Two things you can do:

1) Prevent the user from opening a new tab for your application. For this search google for "preventing multitab 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.


这篇关于阻止两个浏览器选项卡共享相同的会话值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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