Link to home
Start Free TrialLog in
Avatar of mikha
mikhaFlag for United States of America

asked on

custom authorization on controller action and HTML in asp.net mvc

I'm implementing custom authorize attribute in asp.net mvc. I am saving user permissions in a table and created enumeration for it.
in the controller, i Use the attribute on each action method.
but i want to extend it such that, i can apply the permissions to HTML elements as well. say for example,
I have a create new button and i want to display it only if the current user has "create" permission.

is there a way to achieve this. what would be a good way to approach this?

in my CustomAuthorize class, i'm also inheriting from the IActionFilter, to see if i can use it someway to achieve this.

Public enum permissions { create, view , edit ....}

public class CustomAuthorize : AuthorizeAttribute, IActionFilter {

   protected override bool AuthorizeCore(HttpContextBase context){
      //database call to get the user permissions
   }
}
ASKER CERTIFIED SOLUTION
Avatar of Myles Cardiff
Myles Cardiff
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial