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

前端 未结 7 1367

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:23

    If all of your admin code is in one controller then add Authorize to the entire class.

    [Authorize]
    public class AdminController : Controller
    {
         .......
    }
    

提交回复
热议问题