Internet Programming by Murach ( asp.net Core MVC) QUIZ
Internet Programming
Due date November 26, 2020
1-Authorization refers to the process of
|
|
|
issuing or accepting identities from other websites |
|
|
|
granting a user access to an app |
|
|
|
validating the identity of the user |
|
|
|
supplying a username and password |
2-Individual user account authentication
|
|
|
typically authenticates users by displaying a login page |
|
|
|
typically accepts identities from other web apps |
|
|
|
typically authenticates users by displaying a dialog box |
|
|
|
always uses Windows accounts to authenticate users |
3-Which of the following is NOT a property of the IdentityUser class?
|
|
|
|
|
|
|
UserName |
|
|
|
FirstName |
|
|
|
Password |
4-Which of the following is NOT a property that you can use to configure password options?
|
|
|
RequiredLength |
|
|
|
RequireStrong |
|
|
|
RequireDigit |
|
|
|
RequireNonAlphanumeric |
5-Who can access the pages displayed by the List action in the Customer controller shown below?
public class CustomerController : Controller
{
[Authorize(Roles = "Manager")]
[HttpGet]
public IActionResult List() {...}
}
|
|
|
Only users who are logged in |
|
|
|
All users |
|
|
|
Anonymous users |
|
|
|
Only users who are logged in and members of the Manager role |
6-To add the Identity tables to the DB context class, you can code an entity class named User that inherits the IdentityUser class and a DB context class that
|
|
|
inherits the DbContext<User> class |
|
|
|
includes a DbSet<IdentityUser> property |
|
|
|
inherits the IdentityDbContext<User> class |
|
|
|
includes a DbSet<User> property |
7-Which method can you use to add the Identity service to the HTTP request and response pipeline?
|
|
|
ConfigurePassword() |
|
|
|
UseAuthorization() |
|
|
|
AddIdentity() |
|
|
|
UseAuthentication() |
8-Which method of the UserManager<T> class can you use to create a user in the AspNetUsers table?
|
|
|
Create() |
|
|
|
SaveUser() |
|
|
|
CreateUser() |
|
|
|
CreateAsync() |
9-Who can access the pages displayed by the Account controller shown below?
[Authorize]
public class AccountController : Controller {}
|
|
|
Only users who are logged in and members of the Authorize role |
|
|
|
All users |
|
|
|
Only users who are logged in |
|
|
|
Anonymous users |
10-Given a SignInManager<User> object named signInManager and a User object named user, which of the following attempts to log in the user?
|
|
|
await signInManager.LogInAsync(user); |
|
|
|
signInManager.LogIn(user); |
|
|
|
await signInManager.SignInAsync(user, isPersistent: false); |
|
|
|
signInManager.SignIn(user, isPersistent: false); |
11-You can use roles to
|
|
|
define groups of users for social media |
|
|
|
assign the same password to a group of users |
|
|
|
define groups of anonymous users |
|
|
|
apply the same access rules to a group of users |
12-Given a RoleManager<IdentityRole> object named roleManager and a variable named id that stores an id for an existing role, which of the following statements deletes the role?
|
|
|
IdentityUser user = await roleManager.FindByIdAsync(id); await roleManager.RemoveFromRoleAsync(user); |
|
|
|
IdentityRole role = roleManager.FindById(id); roleManager.Delete(role); |
|
|
|
IdentityRole role = await roleManager.FindByIdAsync(id); await roleManager.DeleteAsync(role); |
|
|
|
Role role = await roleManager.FindById(id); roleManager.Remove(role); |