今天发现在一个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不变.

posted on 2009-09-15 09:50  Molby Home  阅读(12215)  评论(7编辑  收藏  举报