Which code segment should you use?

You are creating an ASP.NET Web site. The site is configured to use Membership and Role
management providers. You need to check whether the currently logged-on user is a member of a
role named Administrators. Which code segment should you use?

You are creating an ASP.NET Web site. The site is configured to use Membership and Role
management providers. You need to check whether the currently logged-on user is a member of a
role named Administrators. Which code segment should you use?

A.
Dim isMember As Boolean =
Roles.GetUsersInRole (“Administrators”).Any()

B.
Dim isMember As Boolean =
Membership.ValidateUser ( User.Identity.Name , “Administrators”)

C.
Dim isMember As Boolean =
Roles.GetRolesForUser (“Administrators”).Any ()

D.
Dim isMember As Boolean = User.IsInRole (“Administrators”)



Leave a Reply 0

Your email address will not be published. Required fields are marked *