문제

how can I show button for specific user and hide it for another one based on security role in ASP.NET MVC 2.

For example if I have Create button in my view how to show it only for admin and hide it for any other user.

Thanks.

도움이 되었습니까?

해결책

<% if (User.IsInRole("admins"))
{ %>
    <input type="button" value="Create" />
<% } %>

Where "admins" is the name of your Role

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top