做一个ASP.NET网站的更改杀死活动会话?

前端之家收集整理的这篇文章主要介绍了做一个ASP.NET网站的更改杀死活动会话?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我担心我的用户会话被扫除的可能性.我正在使用默认的ASP.NET Session对象和会话cookie.我知道会话可以超时,我已经将会话的超时值设置为几个小时,以避免超时.

但至少还有另外两个我担心的情况.

(1)我了解ASP.NET定期回收运行网站/网络应用程序的应用程序域(不知道我是否在这里使用所有术语).这些回收事件是否会进行会话?

(2)至少在我的开发服务器上,对网站进行的某些更改(例如,添加页面)似乎会导致活动会话在重新编译网站(或其一部分)时丢失.这似乎并没有发生在每一个变化,但很多它做.我特别关心这是什么意思,在我的网站生活的可能性的变化.我想知道我可以更新的规则,而不会导致活动会话被杀死.

感谢任何指针.

解决方法

这取决于你的会话状态模式.这里有一个你可以在 Microsoft Support找到的东西的副本:

ASP.NET supports three modes of
session state:

  • InProc: In-Proc mode stores values in the memory of the ASP.NET
    worker process. Thus,this mode offers
    the fastest access to these values.
    However,when the ASP.NET worker
    process recycles,the state data is
    lost.
  • StateServer: Alternately,StateServer mode uses a stand-alone
    Microsoft Windows service to store
    session variables. Because this
    service is independent of Microsoft
    Internet Information Server (IIS),it
    can run on a separate server. You can
    use this mode for a load-balancing
    solution because multiple Web servers
    can share session variables. Although
    session variables are not lost if you
    restart IIS,performance is impacted
    when you cross process boundaries.
  • sqlServer: If you are greatly concerned about the persistence of
    session information,you can use
    sqlServer mode to leverage Microsoft
    sql Server to ensure the highest level
    of reliability. sqlServer mode is
    similar to out-of-process mode,except
    that the session data is maintained in
    a sql Server. sqlServer mode also
    enables you to utilize a state store
    that is located out of the IIS process
    and that can be located on the local
    computer or a remote server.

如果您使用StateServer或数据库,当IIS检测到网站的更改时,会话数据将不会丢失.

原文链接:https://www.f2er.com/aspnet/246740.html

猜你在找的asp.Net相关文章