放什么在会话变量 [英] What to put in a session variable

查看:138
本文介绍了放什么在会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近跨就把东西全堆在会话变量中的ASP 1.1 Web应用程序来了。它最终被巨大的。当Web会话超时(用户四小时后已使用的应用程序完成了),有时他们的数据库事务得到回滚。我猜想这是因为DB连接没有被正确当IIS杀死会议闭幕。

I recently came across a ASP 1.1 web application that put a whole heap of stuff in the session variable - including all the DB data objects and even the DB connection object. It ends up being huge. When the web session times out (four hours after the user has finished using the application) sometimes their database transactions get rolled back. I'm assuming this is because the DB connection is not being closed properly when IIS kills the session.

不管怎样,我的问题是应该在会话变量是什么?显然,有些事情需要在那里。该计划的用户选择他们想要编辑在主屏幕上,因此计划ID进入会话变量。它是更好地尝试和存储用户的所有细节,减少对数据库的负荷(和他们的经理等),他们正在编辑在会话变量或者我应该尽量减少在会话变量的东西的计划,查询数据库的一切,我需要在Page_Load事件?

Anyway, my question is what should be in the session variable? Clearly some things need to be in there. The user selects which plan they want to edit on the main screen, so the plan id goes into the session variable. Is it better to try and reduce the load on the DB by storing all the details about the user (and their manager etc.) and the plan they are editing in the session variable or should I try to minimise the stuff in the session variable and query the DB for everything I need in the Page_Load event?

推荐答案

这是pretty很难回答,因为它是如此特殊应用,但这里是我使用的一些准则:

This is pretty hard to answer because it's so application-specific, but here are a few guidelines I use:


  1. 在会议上把尽可能少。

  2. 特定于用户的选择,只有应该在给定访问期间持续是一个不错的选择

  3. 的时候,需要将整个用户访问多个页面到您的网站访问的变量(以避免页面传递他们页)也很好放在会话。

从一点点你说你的应用程序中,我可能会从数据库中选择数据,并试图找到方法,尽量减少这些查询,而不必加载下来会话的影响。

From what little you've said about your application, I'd probably select your data from the db and try to find ways to minimize the impact of those queries instead of loading down the session.

这篇关于放什么在会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆