Add the following lines after created authentication cookie. It will assign role for authenticated context user.
string[] str = new string[1];
str[0] = "User";
HttpContext.Current.User = new GenericPrincipal(User.Identity,str);
you can also assign "str" by getting the user role from the database. After added this coed you can check the authenticated user role like this....
if (HttpContext.Current.User.IsInRole("User"))
{
return true;
}
Above code will return true.
No comments:
Post a Comment