What is the code for determining if a user is in a role?
I have set up all the users through the ASP.NET Configuration Security tab but now want to put logic around
if (User.IsInRole("rolename")) {
// my action
}
Check out the Roles class, specifically IsUserInRole, GetUsersInRole, AddUserToRole, etc.
I use these all the time.
Easy~
HttpContext.Current.User.IsInRole("roleName")
thanks to "Chris Van Opstal". i solved my problem like this way,
public ActionResult Index()
{
if (User.IsInRole("Supervisor"))
{
return RedirectToAction("Index", "InvitationS");
}
return View();
}