今天发现在一个Asp.net站点中, 同一次登录, 不停刷新页面, 此时后台Session的SessionID总是变化的. 经过调查发现, 只要在Global.ascx中加入:

<script>

void Session_Start(object sender, EventArgs e)
{
    // Code that runs when a new session is started

}

void Session_End(object sender, EventArgs e)
{
    // Code that runs when a session ends.
    // Note: The Session_End event is raised only when the sessionstate mode
    // is set to InProc in the Web.config file. If session mode is set to StateServer
    // or SQLServer, the event is not raised.

}

</script>

就可保证同一次会话的SessionID不变.

相关文章:

  • 2022-12-23
  • 2021-04-03
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
  • 2021-09-09
猜你喜欢
  • 2021-12-26
  • 2021-12-30
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案