哪个是存储会话的最佳方法,在HashTable中或单个定义单个。需要你们的更多建议 [英] Which is the best method to store a session, in a HashTable or define single by single. Need more advice from you guys

查看:64
本文介绍了哪个是存储会话的最佳方法,在HashTable中或单个定义单个。需要你们的更多建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!我对存储多个会话值的最佳方法感到困惑。我的一位朋友告诉我们,3-4次定义会话很重,而不是在HashTable中定义。如下所示:问题是哪一个更好?为什么。

 Hashtable ht =  new  Hashtable(); 
ht.Add( UserID,txtUser.Text);
ht.Add( Type,type.Text);
ht.Add( PaypalID,paypal.Text);
会话[ hashtab] = ht; // - 这是一种更好的方式还是一种方式。



会话[  UserID ] = txtUser.Text; 
会话[ 类型] = type.Text;
会话[ PaypalID] = paypal.Text;





请点亮上面的情景我的TL告诉我哈希表需要服务器上的次要内存(假设它需要500 kb)而不是一个接一个(假设需要3MB)。



任何建议真的很感激!我真的需要你们的更多建议。

解决方案

哈希表只是一个额外的开销,所以我看不出任何用处。



唯一的小优势可能是你需要将一组特定的会话值存储起来进行跟踪。

但除此之外,我没有看到任何其他哈希表的使用。


Hi Guys ! I have some confusion over best way to store multiple session values. One of my friend told us that define session 3-4 times is heavy rather then define in a HashTable. Like below scenario : The question is which is better one & why.

Hashtable ht = new Hashtable();
ht.Add("UserID", txtUser.Text);
ht.Add("Type", type.Text);
ht.Add("PaypalID", paypal.Text);
Session["hashtab"] = ht;          //-- Is this better way or below one.


Session["UserID"] = txtUser.Text;
Session["Type"] = type.Text;
Session["PaypalID"] = paypal.Text;



Please light over that in upper scenario my TL told me that hashtable takes minor memory on the server (suppose it takes 500 kb) rather than one by one (suppose it takes 3MB).

Any Suggestions really appreciate ! I really need more advice from you guys.

解决方案

The hashtable would just be an additional overhead, so I don''t see any use for it.

The only minor advantage could be if you need to store a particular group of session values together for tracking.
But other than that, I don''t see any use for an additional hashtable.


这篇关于哪个是存储会话的最佳方法,在HashTable中或单个定义单个。需要你们的更多建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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