Ancient
Ancient

Reputation: 3057

Role based access to url in asp.net mvc

I am building a website with asp.net mvc 4. I using basic role management . The thing i want to do is that i want to give access to any url based on users's role. I was thinking that can we do this via Custom Filter . Because i don't want to write Role attribute on each action . So What i think is i am going to define role based urls in database and then on OnActionExecuted event i want to check that the requested url is allowed to current user or not . Is this possible ?

Upvotes: 1

Views: 408

Answers (1)

SBirthare
SBirthare

Reputation: 5137

While it is possible I will not do it for following reasons:

  1. OnActionExecuting event is pretty early in application execution pipeline. Doing heavy operations that involves going to database should be avoided.
  2. As your application grows, it could create maintenance problem. Hundreds of users, hundreds of links, # roles, etc.

Upvotes: 1

Related Questions