如何在同一浏览器中使用相同的URL限制不同选项卡中的多个会话? [英] How to restrict multiple sessions across different tabs with in the same url in the same browser?

查看:97
本文介绍了如何在同一浏览器中使用相同的URL限制不同选项卡中的多个会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,同样我已成功登录。然后我需要限制用户成功打开一个带有相同网址的新标签。

i已经习惯用ASP.NET开发C#,



我尝试了什么:



我使用的是浏览器IE 11.



会话在同一浏览器的不同选项卡中处于活动状态。

解决方案

这是一种正常行为,因为Session基于浏览器实例和所有选项卡实例。此外,会话存储在服务器中。服务器对客户端浏览器选项卡和Windows一无所知。



请阅读以下讨论,了解如何解决此问题:



如何防止多个浏览器窗口在asp.net中共享同一个会话 - Stack Overflow [ ^ ]

< a href =https://stackoverflow.com/questions/2829228/way-around-asp-net-session-being-shared-across-multiple-tab-windows> .net - 共享ASP.NET会话的方式跨多个选项卡窗口 - 堆栈溢出 [ ^ ]

Session是基于浏览器实例的服务器端摘要。



出于安全原因,标签彼此隔离,并且信息对其他标签既不可见也不可供服务器使用。



可以做的是利用javascript的window.name属性。它的设计更多是为了打开新的窗口/标签,但是在建立连接后为其指定了一个名称。在显示内容之前,您需要利用then来验证window.name。

我已经使用了几年,但遗憾的是我不记得我用过的代码了。 />


这是一个可以在IE中运行的概念验证 - 从本地文件运行它会产生脚本警告。



 <   html  >  
< head >
< title > 测试窗口名称< / title < span class =code-keyword>>
< script <温泉n class =code-attribute> type = text / javascript > window .name = MyWindowsName; < / script >
< / head >
< body >
< h1 >
此窗口的名称为:
< script type = text / javascript > document .write( window .name); < / script >
< / h1 >
< / body >
< / html >


I have an application and in the same I have logged in successfully. Then I would need to restrict the user to open a new tab with same url successfully.
i have used to developing in ASP.NET WITH C#,

What I have tried:

I am using the browser IE 11.

Session is active across different tabs of the same browser.

解决方案

That's a normal behavior as Session is based on the browser instance and all the tab within the instance.In addition, Sessions are stored in the server. A server doesn't know anything about client browser tabs and Windows.

Give the following discussions a read on how to get around this:

How to prevent multiple browser windows from sharing the same session in asp.net - Stack Overflow[^]
.net - Way around ASP.NET session being shared across multiple tab windows - Stack Overflow[^]


Session is a server side abstract based on an instance of a browser.

Tabs are fenced off from one another for security reasons, and the information is neither visible to other tabs nor available to the server.

What can be done is to utilize javascript's "window.name" property. It was designed more for opening new windows/tabs but by assigning a name to it after the connection is made. You would need to utilize then to validate the window.name before displaying content.
It has been a few years since I have worked with this and I unfortunately do no remember the code I had used.

Here is a Proof-of-Concept which does work in IE- running this from a local file will generate a script warning though.

<html>
	<head>
		<title>Test Window Name</title>
		<script type ="text/javascript">window.name="MyWindowsName";</script>
	</head>
	<body>
		<h1>
			The name for this window is:
			<script type ="text/javascript">document.write(window.name);</script>
		</h1>
	</body>
</html>


这篇关于如何在同一浏览器中使用相同的URL限制不同选项卡中的多个会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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