【问题标题】:Timeout Notification Telerik problem with browser multi tab浏览器多选项卡的超时通知 Telerik 问题
【发布时间】:2019-01-22 20:44:24
【问题描述】:

当用户在两个选项卡(同一浏览器)中打开网站时。然后,用户在第一个打开的选项卡上工作 5 分钟(时间设置为超时),会话将过期,因为第二个选项卡仍然没有任何操作(将出现 telerik:RadNotification)。

两个选项卡共享相同的会话 ID。使用 SessionState 模式 = "InProc"。

如何避免这种行为并能够打开多个标签?

【问题讨论】:

标签: c# asp.net telerik


【解决方案1】:

您似乎已将会话超时设置为 5 分钟。 无论您尝试什么,会话超时都会在 5 分钟后发生。

您可以尝试的一种方法是使其过期。这样,您的会话超时将在每次与页面交互后移动 5 分钟。

但即使在这种情况下,如果您打开多个选项卡并且未在任何选项卡中执行任何操作,您的会话将过期,因为会话超时基于 cookie,并且通常在所有现代浏览器中,cookie 是跨选项卡共享的。

如果回发在会话超时时间内没有发生,则会话过期。 您必须确保将某种信息发送到服务器以保持会话活动。

一种解决方案是元刷新,如 in this blog. 所述:

在主文件中包括:

<IFRAME ID="KeepAliveFrame" src="KeepSessionAlive.aspx" frameBorder="0" width="0" height="0" runat="server"></IFRAME>

KeepSessionAlive.aspx:

<meta id="MetaRefresh" http-equiv="refresh" content="21600;url=KeepSessionAlive.aspx" runat="server" />
<script language="javascript">
   window.status = "<%=WindowStatusText%>";
</script>

KeepSessionAlive.aspx.cs

protected string WindowStatusText = "";

protected void Page_Load(object sender, EventArgs e)
{
   if (User.Identity.IsAuthenticated)
   {
      // Refresh this page 60 seconds before session timeout, effectively resetting the session timeout counter.
      MetaRefresh.Attributes["content"] = Convert.ToString((Session.Timeout * 60) - 60) + ";url=KeepSessionAlive.aspx?q=" + DateTime.Now.Ticks;
      WindowStatusText = "Last refresh " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
   }
}

【讨论】:

  • 这是我的问题 -> 当我打开多个选项卡并且在其中不执行任何操作(仅在一个选项卡中工作)时。我在 5 分钟后被踢出,因为会话在其他选项卡中已过期。使用 Chrome。
  • 但是你没有设置滑动过期,这就是它发生的原因。您必须设置滑动到期,然后它应该可以按您的意愿工作。
  • 对不起,没有在 cmets 中提及。我设置了slidingExpiration="true"。测试过,还是一样的问题。
  • 你的认证超时和会话超时不一样吗?
  • 更新了我的答案。我建议阅读有关身份验证 cookie 超时与会话超时的信息,以便更好地了解会话超时以及为什么需要刷新。
猜你喜欢
  • 1970-01-01
  • 2018-09-05
  • 2011-10-19
  • 1970-01-01
  • 2015-11-25
  • 1970-01-01
  • 1970-01-01
  • 2015-11-04
  • 1970-01-01
相关资源
最近更新 更多