在 asp.net 的另一个选项卡中打开 url 时如何更改会话

发布于 2024-12-02 01:32:23 字数 104 浏览 4 评论 0原文

我正在 asp.net 中开发一个 Web 应用程序。我正在弹出窗口中打开所有页面。当有人复制 url 并将其粘贴到另一个选项卡中时,我想使会话过期或更改会话值。我怎样才能实现它? 请帮帮我。

I am developing one web application in asp.net. I am opening my all pages on pop up window. I want to expire my session or change the session value when someone copy the url and paste it into another tab. How can i implement it ?
Please help me out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等你爱我 2024-12-09 01:32:23

一种简单的方法是检查 Request.UrlReferrer。如果用户复制粘贴 URL,Referrer 将为空。

在使用此功能之前,您应该考虑以下几点:

  1. 为可以直接输入的任何页面提供例外
    用户。对于例如登录页面或可以添加书签的页面,
  2. 我相信可以从 Javascript 打开弹出窗口,而无需引用者。确保您现有的代码没有使用此方法打开弹出窗口。

有关确定用户是否打开新选项卡的通用方法,请参阅此处

A simple way would be to check Request.UrlReferrer. The Referrer would be empty if the user copy pastes a URL.

A couple of points you should consider before using this:

  1. Provide exceptions for any pages that can be directly entered by
    the user. For e.g. the login page or a page that can be bookmarked
  2. I believe a pop can be opened from Javascript, without a referrer. Make sure your existing code is not using this method to open a pop up.

For a generic way to determine if the user has opened a new tab, see here

眼中杀气 2024-12-09 01:32:23

我已经用这个解决了这个问题

   string referer = Request.ServerVariables["HTTP_REFERER"];
        if (string.IsNullOrEmpty(referer))
        {
            Response.Redirect("../Index.htm");
        }

I have solved this problem by using this

   string referer = Request.ServerVariables["HTTP_REFERER"];
        if (string.IsNullOrEmpty(referer))
        {
            Response.Redirect("../Index.htm");
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文