- what I would like to do is when the first time app will load I will store Menu in client-side sessionStorage and next time any page load get menu from sessionStorage
- My website flow is LoginPage > Dashboard page
- Dashboard page renders as index.csHtml and uses _Layout.csHtml partial view to the reader
- I successfully store sessionStorage value on client-side but I am not able to get this save value in _Layout.csHtml Page.
- In _Layout.csHtml body part this code use
@{Html.RenderAction("RenderTopMenu", "Common");}
and I need to pass sessionStorage value in this RenderAction
EX: @{Html.RenderAction("RenderTopMenu", "Common", new {model=sessionStorage});}
PAGE - Index.csHtml
@{
ViewBag.Title = "Welcome To " + SessionManagement.CompanyName;
Layout = (ViewBag.isPartialView) ? null : "~/Views/Shared/_Layout.cshtml";
}
PAGE - _Layout.cshtml
<!DOCTYPE html>
<html>
<head>
</head>
<body class="pageContent">
@{Html.RenderAction("RenderTopMenu", "Common");}
</body>
PAGE - Controller
public ActionResult RenderTopMenu(DashboardViewModel AdminMenus)
{
DashboardViewModel Dashboardmodel = new DashboardViewModel();
Dashboardmodel = DashboardModel.GetTopMenu(Dashboardmodel);
}
PAGE - Model
public List<AdminMenus> GetMenuListFromCache(int AccountMode, DashboardViewModel Dashboardmodel)
{
List<AdminMenus> AdminMenusList = sessionStorage.getitem("Menu") as List<AdminMenus>;
if (AdminMenusList == null) //not in cache
{
AdminMenuParamsModel menus = new AdminMenuParamsModel()
{
CompanyID = SessionManagement.IntCompanyID,
MenuID = AccountMode
};
AdminMenusList = new DashboardBLL(SessionManagement.DevPasswordConnectionString).ProcessGetMenus(menus);
AdminMenusList = DashboardModel.SetMenuName(AdminMenusList);
sessionStorage.setitem("Menu") = AdminMenusList;
}
return AdminMenusList;
}
NOTE: In a model for only explanation purpose I put sessionStorage.getitem but really I can not use this.