I have created a custom attribute ‘RoleAction’ and added to the model property
public class RoleActionAttribute : Attribute
{
public string UserRole { get; set; }
public RoleActionAttribute(string Role)
{
this.UserRole = Role;
}
}
[RoleAction("Manager")]
public EmployeeName
How to I get the RoleAction value (Manager) in my mvc view page.
You could use Reflection in order to fetch custom attributes:
Another possibility is to use Metadata and make your custom attribute metadata aware by implementing the new IMetadataAware interface that was introduced in ASP.NET MVC 3:
and then: