How can we set authorization for a whole area in ASP.NET MVC?

前端 未结 7 1345

I\'ve an Admin area and I want only Admins to enter the area. I considered adding the Authorized attribute to every controller in the Admin area. Isn\'t there an elegant sol

相关标签:
7条回答
  • 2020-12-08 04:38

    .. very crudely I believe you want something like this?

    Quick and dirty role management

    [Authorize(Roles = "Admins")]
    public ActionResult Register()
    {
      ViewData["roleName"] = new SelectList(Roles.GetAllRoles(), "roleName");
      ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
      return View();
    }
    
    0 讨论(0)
提交回复
热议问题