Why HttpContext.Current.User.IsInRole(“Customer”) returns false if the user is not logged in, I think because user is considered anonymous is this case, Correct?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you are correct. Anonymous users cannot belong to a role.
Notice that the
Userobject for an anonymous user is aGenericPrincipaland while it implementsIPrincipal, theIsUserInRolemethod always returns false because there are no roles supplied when it is created byFormsAuthenticationModule.Also notice that the
Userobject for an authenticated user is aRolePrincipal, which queriesRoleManagerinIsUserInRole.