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

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -