我具有哈希表形式的Session值,并且必须使用模型绑定来显示此数据,因此我必须将其转换为该模式的列表并显示到视图中 我尝试过的是:
public actionResult cart()
{
Hashtable ht = (Hashtable)Session["cart"];
List<cart> cart=new List<cart>();
cart = (List<cart>)(Hashtable)Session["cart"];
return View("cart",cart);
}
此处包含会话值
防御
if (Session["cart"] != null)
{
Hashtable ht = (Hashtable)Session["cart"];
var mydata = new List<cart>
{
new cart { mid= mid,mprize = mrate },};
//Hashtable ht = new Hashtable();
ht.Add(mid,mydata);
Session["Cart"] = ht;
}
和如何访问此哈希表值以在我的上下文中显示?