Asp.net mvc 2 无法在会话中存储哈希表-Asp.net MVC3

Asp.net mvc 2 无法在会话中存储哈希表-Asp.net MVC3,asp.net-mvc-2,session,hashtable,Asp.net Mvc 2,Session,Hashtable,在我的应用程序中,我想在会话中存储一个哈希表,然后从会话中检索 代码如下所示 Hashtable ht = new Hashtable(); DateTime fromDate = Convert.ToDateTime(dt.Rows[0]["FromDate"]); DateTime toDate = Convert.ToDateTime(dt.Rows[0]["ToDate"]);

在我的应用程序中,我想在会话中存储一个哈希表,然后从会话中检索

代码如下所示

     Hashtable ht = new Hashtable();
                   DateTime fromDate = Convert.ToDateTime(dt.Rows[0]["FromDate"]);
                   DateTime toDate = Convert.ToDateTime(dt.Rows[0]["ToDate"]);
                   ht["StartTime"] = fromDate;
                   ht["EndTime"] = toDate;
                   Session["RuleSearchParameterForArchive"] = ht;
  Hashtable hts = (Hashtable)Session["RuleParametersForArchive"];
                   DateTime dd = Convert.ToDateTime(hts["EndTime"]);
调试时,我可以看到哈希表ht包含两个值(StartTime和EndTIme)。。但当我检索时,它总是为空。。代码如下所示

     Hashtable ht = new Hashtable();
                   DateTime fromDate = Convert.ToDateTime(dt.Rows[0]["FromDate"]);
                   DateTime toDate = Convert.ToDateTime(dt.Rows[0]["ToDate"]);
                   ht["StartTime"] = fromDate;
                   ht["EndTime"] = toDate;
                   Session["RuleSearchParameterForArchive"] = ht;
  Hashtable hts = (Hashtable)Session["RuleParametersForArchive"];
                   DateTime dd = Convert.ToDateTime(hts["EndTime"]);
在调试时,我可以看到hastable hts持有空值。为什么我无法从会话中检索值。
有什么想法吗?

哈希表存储的键(RuleSearchParameterForArchive)与您在尝试检索时使用的键(RuleParametersForArchive)不同。

非常感谢。愚蠢的事情..但我浪费了很多时间。我必须在编码时更加小心:(