在MVC使用Session对象,是不是真的不好? [英] Using Session objects in MVC, Is it really bad?

查看:175
本文介绍了在MVC使用Session对象,是不是真的不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建议使用一个简单的会话对象在MVC3维护状态数据,如RecordIds,而不是通过所有这将是一个麻烦的客户端页面通过他们。这似乎简单得多,只是填充会话对象一次,直到不再使用。

I am proposing to use a simple session object in a MVC3 to maintain state data like RecordIds rather than pass them through all the client side pages which will be a hassle. It seems far simpler to just populate the session object the once until no longer in use.

所以这是可以接受的做法或作弊?

So is this acceptable practice or a cheat??

非常感谢。

推荐答案

有什么错误使用Session对象。通常人们避免他们减少服务器上的负载;但如果你的小心的,不要试图把大量的数据在那里,并没有太多的(有多少是太多取决于您的服务器上),那么它是一个可以接受的做法。

There's nothing wrong with using Session objects. Generally people avoid them to reduce the load on the server; but if you're careful and don't try to put lots of data in there and don't have too many (how many is too many depends on your server) then it is an acceptable practice.

有关使用会话的潜在缺点一些信息请查看答案来的Still确定在ASP.NET MVC中使用Session变量,或者是有一些事情是更好的选择(如车)

For some info on the potential drawbacks of using sessions check out the answer to Still ok to use Session variables in ASP.NET mvc, or is there a better alternative for some things (like a cart)

这篇关于在MVC使用Session对象,是不是真的不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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