Last post May 06, 2019 07:38 AM by Yuki Tao
May 06, 2019 04:12 AM|demoninside9|LINK
In my application when a user logs in, I am binding menu based on the user role / authorization.
I am doing this by using sessions. See the code below for example. And it is working fine
<ul class="nav navbar-nav">
@if (Session["MenuMaster"] != null)
var MenuMaster = (List<CP.Models.MenuModel>)Session["MenuMaster"];
var groupByMenu = MenuMaster.GroupBy(x => x.MainMenuName).ToList();
foreach (var MenuList in groupByMenu)
<a class="dropdown-toggle" data-toggle="dropdown" href='@Session["_Logo"]+""'>@MenuList.Key<span class="caret"></span></a>
@foreach (var SubMenuList in MenuList)
My question is: is it ok to use sessions for this type of activities?
May 06, 2019 07:38 AM|Yuki Tao|LINK
You could refer to this form:
Maintains data between
Controller to Controller
Controller to View
View to Controller
If you just pass data from contrller to view,I suggest you could use ViewBag.
Because the session has a possibility of failure