Im trying to hide some admin specific buttons on my masterpage from users with no adminrights.
my code looks like this so far:
<% if (Request.IsAuthenticated)
{%>
<%: Html.ActionLink("Administrer", "Index", "User", new { Area = "Users" }, new { @class = "menubutton", @id = "settingsbutton" })%>
<%} else { }%>
now i want to do a check in the IF() statement if the current user is an administrator. im using the ASP.NET membership system and have a speciel class attached to each user with some exstra information including information about if he is an admin or not (bool).
my question is how do i go about calling a method that checks this or something similar?
If you are using the ASP.NET Membership Provider and the ASP.NET Role Provider to link your users to their roles, you can just invoke the
IsInRole(string) method on your view’sIPrincipal Userobject.