nerdexam
Microsoft

70-515 · Question #16

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…

The correct answer is D. bool isMember = User.IsInRole("Administrators"). See the full explanation below for the reasoning.

Question

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?

Options

  • Abool isMember = Roles.GetUsersInRole("Administrators").Any();
  • Bbool isMember = Membership.ValidateUser(User.Identity.Name,
  • Cbool isMember = Roles.GetRolesForUser("Administrators").Any();
  • Dbool isMember = User.IsInRole("Administrators");

How the community answered

(18 responses)
  • A
    11% (2)
  • B
    6% (1)
  • D
    83% (15)

Community Discussion

No community discussion yet for this question.

Full 70-515 Practice