security - Could I make dynamic render rely User Permissions in MVC 2? -


i make security system in mvc application. in mvc must done authorizeattribute , roles string via actions methods.

could make stuff: instead of action resolve want make view html parts hidden depend on current user permission set (for example: save button not visible if user not administrator).

within views, can conditional checks, such as:

<% if (user.isinrole("admin")) { %>     <a href="#">an admin-only link</a> <% } %> 

in partial views, user property not exposed, can still it:

<% var user = httpcontext.current.user; %>  <% if (user.isinrole("admin")) { %>     <a href="#">an admin-only link</a> <% } %> 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -