Cant store Hash table in session - Asp.net MVC3
In my application I want to store a hash table in session and retrieve later from session.
The code is shown below
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;
While debuggin i can see that hashtable ht hold two values (StartTime and EndTIme) .. But when i retri开发者_JS百科eving ,that always give null .. code is shown below
Hashtable hts = (Hashtable)Session["RuleParametersForArchive"];
DateTime dd = Convert.ToDateTime(hts["EndTime"]);
While debugging i can see that hastable hts holds null value. Why i cant retrieve value from session. Any ideas??
The hashtable is stored with a different key (RuleSearchParameterForArchive) than you use when attempting to retrieve it (RuleParametersForArchive).
精彩评论