asp.net - User permissions on certain views based on roles -


i using asp.net mvc 3. please excuse terminology. assign roles people @ work, use windows authentication determine roles user has. lets roles rolea, roleb , rolec. list of roles user. lets says usera belongs rolea , roleb. of views need authenticated not can view views. lets viewa can viewed users belong roles rolea , roleb. how this? need into? when user not belong these roles tries access views he/she should redirected error page.

also, need sort of helper method check these roles used in views hide/display controls. best place use this?

any sample code / articles appreciated.

[authorize(roles = "rolea,roleb")] public actionresult foo() {     return view(); } 

and if want check roles in view:

@if (user.isinrole("rolea")) {     <div>this visible users in rolea</div> } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -