Why does my ASP.Net static function's “context” crossover between user sessions?

后端 未结 5 1067
醉酒成梦
醉酒成梦 2020-12-16 03:58

I think I need some help understanding how static objects persist in an ASP.Net application. I have this scenario:

someFile.cs in a class library:

p         


        
5条回答
  •  悲&欢浪女
    2020-12-16 04:34

    If you want the data to persist only for the current request, use HttpContext.Items: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.items.aspx

    If you want the data to persist for the current user's session (assuming you have session state enabled), use HttpContext.Session: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.session.aspx

提交回复
热议问题