permissions - Showing/Hiding Links in an ASP.Net MVC View -


I am trying to understand how to show / hide the link for a user based on my roles. I know how to set the attribute for an action method, but if the user says, in my database of roles there is an administrator or manager, then I have trouble creating links in a link.

Any good article or any example of the code can tell me?

In your opinion, you can user System.Web.Mvc. ViewPage 's user via property

user

for example. In your opinion, you might have something like this:

  <% if (User.IsInRole ("Admin")) {%> & Lt;% = Html.ActionLink ("admin only link", "edit", "user")%> & Lt;%}% & gt; & Lt;% if (user.isynol ("manager") || user.isynol ("admin")) {%> & Lt;% = Html.ActionLink ("manager and admin only link", "edit", "product")% & gt; & Lt;%}% & gt;  

HTH,
Charles


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -