C# CoreMVC Final
The @model directive is used to
bind a model to a view
When you code a controller that works with ASP.NET Core Identity, you can inject the UserManager<T>, SignInManager<T>, and RoleManager<T> objects into the controller by
coding them as parameters of the controller's constructor
In an ASP.NET Core MVC app, you can organize the folders and files of the app by creating areas where each area has its own
controllers, models, and views
To decrease reliance on lower level techniques while working with session state, you can add ____________ to the ISession interface that allow you to store and retrieve .NET objects.
extension methods
Authorization refers to the process of
granting a user access to an app
The third segment of the default route specifies an argument for the
id parameter of the specified action method
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 IdentityDbContext<User> class
When you use attribute routing, the route specified by the attribute
overrides any routes that are specified in the Program.cs file
You can pass a model to a view by
passing a model object as an argument to the View() method inside an action method and returning the resulting object
From inside an action method, you can transfer a model to a view by
passing it to the View() method and returning the result
Which of the following is NOT a common web programming technique for maintaining state?
remote procedure call
Which of the following is a technique that is used in ASP.NET Core MVC for maintaining state but is not commonly available outside of this framework?
routes
A _______________ cookie only lasts as long as the browsing session, and a _____________ cookie can last through multiple browser sessions.
session - persistent
To nest one layout inside another, the containing layout should
set its Layout property to the nested layout
To get route information for the current view, a layout can use
the ViewContext.RouteData.Values property
Individual user account authentication
typically authenticates users by displaying a login page
To encapsulate the functionality of another class, it is common to write a
wrapper class
Which pattern specifies the default route for an ASP.NET Core MVC app?
{controller=Home}/{action=Index}/{id?}
If your app uses routes with the following patterns, which route do you need to code first in the Program.cs file?
{controller}/{action}/{category}/page{page}/sort-by-{sortby}
To display a section in a layout, you use the ____________ directive in the view to specify the name and content of the section and then use the ___________ method to display the section in the layout.
@section - RenderSection()
Given a User class that inherits the IdentityUser class, which of the following directives can you use to inject a SignInManager<User> object into a layout?
@using Microsoft.AspNetCore.Identity @inject SignInManager<User> signInManager
What is the following URL an example of? https://www.murach.com/shop-books/all
An absolute URL
A view can access data stored in session state by using the property namedA view can access data stored in session state by using the property named
Context
When you create an area to organize folders and files, you do NOT typically need to perform one of the following tasks. Which one is it?
Create a Route folder to store the routing patterns for the area.
Which method of the UserManager<T> class can you use to create a user in the AspNetUsers table?
CreateAsync()
To enable session state, the Progam.cs file must call all of the following methods except
EnableCookies()
To create a persistent cookie, you must set the ______________ property of the CookieOptions class before adding the cookie to the Response.Cookies collection.
Expires
From within a controller, you can work with session state items by using methods of an interface named
ISession
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?
IdentityRole role = await roleManager.FindByIdAsync(id);
If you perform an HTTP redirect, MVC automatically calls the
Keep() method
Who can access the pages displayed by the Account controller shown below? [Authorize] public class AccountController : Controller {}
Only users who are logged in
Which of the following is NOT a subclass of ActionResult?
PDFResult
Which of the following design patterns prevents resubmission of form data?
PRG
The TempData dictionary is often used with the
PRG pattern
In the following URL pattern, which part is static? {controller}/{action}/{cat}/Page{num}/{sort?}
Page
Within the TempData dictionary, you can mark a value for a key as unread by calling the
Peek() method
Which of the following methods redirects from one action to another?
RedirectToAction()
Which of the following is NOT a property that you can use to configure password options?
RequireStrong
The static _________________ method of the JsonSerializer class can convert a .NET object to a JSON string.
Serialize()
If you need to store data that persists across multiple requests, you should use the
TempData property
If you're using the default route, which action does the following URL call? https:/localhost:5001/
The Index action of the Home controller
If you're using the default route, which action does the following URL call? https:/localhost:5001/customer/list
The List action of the Customer controller
Which of the following is a benefit of well-designed URLs?
They can improve the usability of your app for both developers and end users.
If you are storing data from a controller and need to create a key that contains spaces, you should use the
ViewData property
Given a controller named FoodController with an action method Burgers(), the corresponding view would be mapped by default to
Views/Food/Burgers.cshtml
Which tag helpers can generate the following URL? /Foods/Veg/Samosa
asp-controller="Foods", asp-action="Veg", asp-route-id="Samosa"
The tag helper that can be used to perform binding between properties of a model and HTML elements is
asp-for
The tag helper that can be used to specify the source of values for the <option> elements of a <select> element is
asp-items
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.SignInAsync(user, isPersistent: false);
