几次 window.open 调用后,我的 ASP.NET 会话超时

发布于 2024-08-05 09:20:26 字数 446 浏览 2 评论 0原文

我有一个 ASP.NET 应用程序,它使用 StateServer 会话模式,并将 cookieless 设置为 false。在一些地方,有一个链接会弹出另一个应用程序的窗口(该应用程序恰好驻留在同一域中,但位于不同的虚拟目录中)。以下步骤让我感到悲伤...

  1. 启动弹出窗口
  2. 关闭
  3. 弹出窗口 使用几个不同的参数将弹出窗口启动到与以前相同的应用程序
  4. 关闭弹出窗口
  5. 下一个请求 = “父”窗口上的会话超时。

使用无 cookie 会话可以解决这个问题,因此不知何故我的 cookie 被浏览器删除了。除了使用无 cookie 会话之外,如何解决此问题?无论如何,我正在使用 IE8 进行开发/测试。

编辑

似乎只有当弹出窗口位于同一域时才会出现问题。如果我在其他地方弹出页面,没有问题。

I have an ASP.NET application that uses StateServer session mode with cookieless set to false. In a few places, there is a link that pops up a window to another application (which happens to reside on the same domain, but in a different virtual directory). The following steps give me grief...

  1. Launch popup
  2. Close popup
  3. Launch popup to same app as before with a couple different parameters
  4. Close popup
  5. Next request = session timeout on the "parent" window.

Using cookieless sessions fixes the problem, so somehow my cookie is getting whiped out by the browser. Aside from using cookieless sessions, how can this be resolved? For what it's worth, I am developing/testing with IE8.

EDIT

It seems the problem only occurs when the popup resides on the same domain. If I popup a page elsewhere, there is no problem.

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

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

发布评论

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

评论(3

む无字情书 2024-08-12 09:20:26

其他应用程序(在同一域上)是否有可能设置自己的 cookie,覆盖您的主应用程序的 cookie?您可以使用 fiddler(或类似工具)查看哪些应用程序设置了哪些 cookie?

Is it possible the other app (on the same domain) is setting its own cookie, overwriting that of your primary app? Can you use fiddler (or similar tool) to see which cookies are being set by which apps?

苹果你个爱泡泡 2024-08-12 09:20:26

检查您的所有实例。

Session.Clear();
Session.Abandon();

如果您根本不使用这些实例,则可能是您的浏览器窗口设置为不在之间共享会话。因此,新实例会获得一个新的会话 cookie(因为它的 cookie 名称与前一个实例相同,因此它可能会杀死现有的会话 cookie)——就像下面的游戏一样:
http://geekswithblogs.net/ranganh/archive/2009/04/17/asp.net-session-state-shared- Between-ie-tabs-and-ie8.aspx

最好追踪在哪个页面Set-Cookie 标头出现。然后查看进入该响应的请求,并查看当前的 ASP.NET_SESSIONID cookie 是否已发送。 (fiddler确实是最好的工具)
不管怎样——这是一个尝试的开始。

Check all instances of your

Session.Clear();
Session.Abandon();

If you aren't using those at all, then its likely the case that your browser windows are set to NOT share sessions between. So the new instance gets a NEW session cookie (since its the same cookie name as the prior one, it could possibly kill the existing session cookie)- as in a play on:
http://geekswithblogs.net/ranganh/archive/2009/04/17/asp.net-session-state-shared-between-ie-tabs-and-ie8.aspx

Ideally track down in which page the Set-Cookie header is coming across. Look then at the request going INTO that response and see if your current ASP.NET_SESSIONID cookie is sent over. (fiddler is indeed the best tool for this)
Anyway - its a start to try.

无名指的心愿 2024-08-12 09:20:26

编辑显然这不是你的cookie名称,所以......
也许您应该在母版页上进行 AJAX 调用,以对 Web 应用程序上的服务(或通用处理程序)执行 ping 操作,以保持会话处于活动状态。

JavaScript

window.setInterval(function() { 
    $.get('ping.ashx?nocache=' + (new Date()).getTime(), function() { 
        return true; 
    })
}, 30000);

在通用处理程序中,确保添加 IRequiresSessionState 标记接口。

也许您的会话 cookie 名称是相同的。

在您的 web.config(针对其中一个应用程序)中更改会话 cookie 名称。

<sessionState
mode="StateServer"
timeout="20"
cookieName="DifferentASP.NET_SessionId"

edit Apparently it's not your cookie name, so...
Perhaps you should have an AJAX call on your master page that pings a service (or generic handler) on your web app to keep the session alive.

JavaScript

window.setInterval(function() { 
    $.get('ping.ashx?nocache=' + (new Date()).getTime(), function() { 
        return true; 
    })
}, 30000);

In the Generic Handler, make sure to add the IRequiresSessionState marker interface.

Perhaps your session cookie names are the same.

In your web.config (for one of the applications) change the session cookie name.

<sessionState
mode="StateServer"
timeout="20"
cookieName="DifferentASP.NET_SessionId"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文