Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. if (User.IsInRole("rolename")) {
  2. // what you wan't to do.
  3. }
  4.  
  5. GenericIdentity userIdentity = new GenericIdentity((FormsIdentity)HttpContext.Current.User.Identity.Name);
  6.  
  7. string[] roles = { "rolename1", "rolename2", "rolename3" };
  8. GenericPrincipal userPrincipal = new GenericPrincipal(userIdentity, roles);
  9. Context.User = userPrincipal;
  10.  
  11. if (User.IsInRole("rolename1")) {
  12. // what you wan't to do.
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement