I have a Login page
where on login it takes user to Home Page
where dynamic menu
is loaded.The problem is that when a user clicks on
Create a separate [ChildActionOnly]
method that generates your menu and call it from the layout page so its available in all pages
[ChildActionOnly]
public ActionResult Menu()
{
var model = new DashboardVM
{
....
}
return PartialView("_Menu", model);
}
and create a _Menu.cshtml
partial view to generate the html
@model DashboardVM
....
and then in your layout, remove @model SMS.Models.ViewModel.DashboardVM
(a layout should not have a model unless that model is a base class for all models used by the layout) and then include
@Html.Action("Menu", yourControllerName)
which will call the Menu
method and insert the partial view it returns into the layout.