Click here to Skip to main content
15,031,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to define the controller object in layout page. how to do that.
in layout userservices object and permission ActionMethod are undefined.

What I have tried:

contoller Action Method

  public ActionResult Create()
          //  var userId = Convert.ToInt32(Session["Userid"]);
            if (UserServices.HasPermission(Permissions.Can_Add_User))
                var model = new UsersModel();
                var RoleList = UserServices.GetRolesList();
                ViewBag.RoleList = new MultiSelectList(RoleList, "id", "Name");
                return View(model);

            return RedirectToAction("NotAuthorize", "Error404");


 if (UserServices.HasPermission(Permissions.Can_Add_User))
 <a href="@Url.Action("List","User", new { area="Admin"})" class="nav-link">
      class="far fa-circle nav-icon">

Updated 3-May-21 21:24pm

1 solution

Add the namespace and make the object. problem will be solved

(Namespace of application).UserServices userServices = new (Namespace of application).UserServices();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900