我应该使用ASP.NET会话或避免他们,为什么? [英] Should I use ASP.NET sessions or avoid them and why?

查看:108
本文介绍了我应该使用ASP.NET会话或避免他们,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用ASP.NET会话或避免他们为什么?

Should I use ASP.NET sessions or avoid them and why?

推荐答案

对于新的应用,<一个href=\"http://stackoverflow.com/questions/526697/upgrade-from-net-3-0-to-3-5-sites-set-to-stateserver-revert-to-inproc-when-in-w\">I尽量避免他们,只是preFER的加密或签名的cookie。这是无可否认的只是一个新发现的个人preference:只是因为它的一件事打破,并努力保持网站了全天候两年后,它是在头打破的嘛-scratching,神秘的方式。这也很容易忘记添加在你的对象[Serializable接口],看着他们在运行时炸毁,当他们试图让存储外的进程内的会话。所以这是另一个齿轮磨,可以这么说。

For new applications, I try to avoid them and just prefer an encrypted or signed cookie. This is admittedly just a new-found personal preference: Just because it's one more thing to break, and after working to keep a site up 24/7/365 for two years, it's the only thing that has broken in a head-scratching, mysterious way. It's also easy to forget to add [Serializable] on your objects and watch them blow up at runtime when they try to get stored in an out-of-proc session. So it's another gear to grind, so to speak.

这是说,我一直在使用会话,的的无不仅仅是不必担心保持会话存储和运行​​所有的时间以外的任何显著的问题。如果你是InProc,你不用担心会得到不慎发每次应用程序池重新启动,它可能会导致工作进程内存使用气球,这是另一个缺点;与其他方法之一,它很高兴能够发布一个点更新到网站,并不会影响任何客户当前的状态。

That said, I've been using sessions for years without any significant issues other than just having to worry about keeping the session store up and running all the time. If you're InProc, you have to worry about sessions getting zapped every time the app pool restarts, and it can cause the worker process memory usage to balloon, which is another downside; with one of the other methods, it's nice to be able to release a point update to the Web site and not affect any customer's current states.

(我个人还没有看到有向外扩展的会议,甚至在多个服务器上的问题。但是,有一次我在一家小企业[约3页面访问量/秒。我想你平时所谈论到数据库反正工作的东西,获取了会议的成本是在洗。)

(I personally haven't seen problems with scaling out sessions, even on multiple servers. But then again I work for a small business [about 3 page views/second]. I figure you're usually talking to the database anyway for something, the cost of fetching the session is in that wash.)

因此​​,使用会话是不是一个不错的选择,你只需要记住不要得意忘形它。把它看成是一个服务器端的cookie,试图限制自己的人工4KB左右障碍。对于现有的应用程序,我当然不打扰取消sessionizing他们,但总的来说,我现在preFER保持它的简单和尝试没有做。

So using sessions isn't a bad choice, you just have to remember not to get carried away with it. Think of it as a server-side cookie, trying to limit yourself to an artificial 4KB or so barrier. For existing applications I certainly don't bother un-sessionizing them, but in general I now prefer to keep it simple and try to do without.

这篇关于我应该使用ASP.NET会话或避免他们,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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