本文介绍了使用Session对象时的性能注意事项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all



我有一个简单的ASP.NET应用程序,它有一个表单,然后它查询数据库的结果,在此操作周期中应用程序使用会话变量2或4次(它存储一个DateTime对象和一个布尔变量,如果多次按下某个按钮可能会更多)。我的问题是如何确定我使用Session变量的方式是否以明显的方式影响性能?不仅仅是我的情况,而是一般情况。我已阅读文章,我不明白。



谢谢!。

Hello all

I have a simple ASP.NET application that has a form and then it query a database for a result, during this operation cycle the application uses the session variable 2 or 4 time (it stores a DateTime object and a boolean variable, could be more if some button is pressed more than once). My question is how to determine the way I'm using the Session variable is affecting performance in a noticeable way? Not for my case only but in general. I have read this article and I did not understand it.

Thanks!.

推荐答案

Quote:

为确保优化会话状态性能,请遵循以下准则:

  • 首选基本类型以降低序列化成本。
  • 如果不使用会话状态,则禁用会话状态。
  • 避免将STA COM对象存储在会话状态。
  • 尽可能使用ReadOnly属性。
  • To ensure optimized session state performance, follow these guidelines:

    • Prefer basic types to reduce serialization costs.
    • Disable session state if you do not use it.
    • Avoid storing STA COM objects in session state.
    • Use the ReadOnly attribute when you can.
    • 也可以阅读博客 - []

      Also do read the Blog - SessionState Performance[^]


      这篇关于使用Session对象时的性能注意事项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 08:44
查看更多