Shawn Dao
Shawn Dao

Reputation: 96

Authorize all actions under specific controller (example: adminController)

i want to authorize all action under adminController. how can i do that. i have a database with Roles and User. 1. Administrator 2. Member

i want only Administrators can access to all action in adminController.

Upvotes: 0

Views: 988

Answers (2)

itsmatt
itsmatt

Reputation: 31416

If I follow what you are asking, I've done this to restrict access to the SiteAdminController:

[Authorize(Roles = "Site Admin")]
public class SiteAdminController : BaseController

That restricts access to the actions of my SiteAdminController to users in that role.

Upvotes: 1

Michael Grassman
Michael Grassman

Reputation: 1935

[Authorize(Roles = "Administrator")]
public class controller() {

}

Upvotes: 1

Related Questions