daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top