How to use Session variable object in foreach-MVC5 View

前端 未结 1 390
有刺的猬
有刺的猬 2020-12-20 08:53

I am working on dynamic menus. Using Session Variable by passing whole object. As can be seen from controller:

Session[\"PackageSbMenu2\"] = QueryHelper.Get_         


        
1条回答
  •  囚心锁ツ
    2020-12-20 09:29

    You need to cast your Session object

     @{    
        var menu = Session["PackageSbMenu2"] as List;
        if(menu != null)
        {
            foreach(var t in menu)
            { 
             
  • t.Name
  • } } }

    0 讨论(0)
提交回复
热议问题