Murach Quiz 3
If you perform an HTTP redirect, MVC automatically calls the Xa.Peek() method Xb.Post() method Xc.Seek() method d.Keep() method
d.Keep() method
Within the TempData dictionary, you can mark a value for a key as unread by calling the a.Post() method b.Peek() method Xc.Seek() method d.Keep() method
d.Keep() method
Which of the following design patterns prevents resubmission of form data? a.MVC b.Abstract Factory c.Singleton d.PRG
d.PRG
Which of the following is a benefit of well-designed URLs? a.They make it possible to swap out one component for another component. b.They make it possible to automate testing of individual components. c.They make it easier to have different developers work on different components. d.They can improve the usability of your app for both developers and end users.
d.They can improve the usability of your app for both developers and end users.
The tag helper that can be used to perform binding of items to a <select> element is Xa.asp-items Xb.asp-action Xc.asp-for d.asp-controller
d.asp-controller
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 a.models only b.controllers only c.controllers and views only d.controllers, models, and views
d.controllers, models, and views
The third segment of the default route specifies an argument for the a.slug parameter of the List action method b.id parameter of the List action method c.slug parameter of the specified action method d.id parameter of the specified action method
d.id parameter of the specified action method
From inside an action method, you can transfer a model to a view by a.passing it to the RedirectToAction() method and returning the result b.storing it in the ViewData property and returning that property c.storing it in the ViewBag property and returning that property d.passing it to the View() method and returning the result
d.passing it to the View() method and returning the result
To get route information for the current view, a layout can use Xa.the ViewContext.ViewValues property Xb.the ViewBag.ViewContext property Xc.the asp-route-id tag helper d.the ViewContext.RouteData.Values array
d.the ViewContext.RouteData.Values array
Which pattern specifies the default route for an ASP.NET Core MVC app? a.{controller=Customer}/{action=List}/{id?} b.{controller=Customer}/{action=List}/{id?}/{slug?} c.{controller=Home}/{action=Index}/{id?}/{slug?} d.{controller=Home}/{action=Index}/{id?}
d.{controller=Home}/{action=Index}/{id?}
With the TempData dictionary, you can read a value for a key without having it be marked as read by calling the a.Peek() method b.Post() method c.Keep() method d.Seek() method
a.Peek() method
Which of the following methods redirects from one action to another? a.RedirectToAction() b.View() c.Action() d.ViewAction()
a.RedirectToAction()
If you need to store data that persists across multiple requests, you should use the a.TempData property Xb.ViewData property c.ViewBag property d.ViewContext property
a.TempData property
If you're using the default route, which action does the following URL call? https:/localhost:5001/customer/list a.The List action of the Customer controller b.The List action of the Home controller c.The Index action of the Home controller d.The Index action of the Customer controller
a.The List action of the Customer controller
If you are storing data from a controller and need to create a key that contains spaces, you should use the a.ViewData property b.ViewBag property c.IntelliSense property d.tag helpers
a.ViewData property
You typically create a custom layout in the ______________ folder and apply the layout inside a view in a ___________________. a.Views/Shared - Razor code block b.Views/Shared - Razor if statement c.Views/Home- Razor if statement d.Views/Home - Razor code block
a.Views/Shared - Razor code block
The @model directive is used to a.bind a model to a view Xb.directly access a model object's properties and methods Xc.bind a controller to a model d.provide another syntax for accessing the ViewBag
a.bind a model to a view
One good way to display a model object list in a table is to use a.A Razor if statement b.A Razor foreach loop c.the asp-items tag helper d.the table-data-list tag helper
b.A Razor foreach loop
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? Xa.If it doesn't already exist, create an Areas folder. b.Create a Route folder to store the routing patterns for the area. c.In the Startup.cs file, use the MapAreaControllerRoute() method to map a route for the area's controllers. Xd.Use the Area attribute to associate a controller with the area.
b.Create a Route folder to store the routing patterns for the area.
In the following URL pattern, which part is static? {controller}/{action}/{cat}/Page{num}/{sort?} a.{sort?} b.Page c.Page{num} d.{cat}
b.Page
Which of the following is NOT a best practice for creating URLs? a.Keep the URL as short as possible while still being descriptive and user-friendly. b.Use query string parameters whenever possible. c.Make your URLs easy for humans to understand and type. d.Use keywords to describe the page's content, not its implementation details.
b.Use query string parameters whenever possible.
The C# conditional operator (? :) is used in Razor syntax to create a.a switch statement b.a conditional expression c.an if statement d.a Bootstrap CSS class
b.a conditional expression
Which tag helpers can generate the following URL? /Foods/Veg/Samosa a.asp-controller="Samosa", asp-action="Veg", asp-route-id="Foods" b.asp-controller="Foods", asp-action="Veg", asp-route-id="Samosa" c.asp-controller="Foods", asp-action="Samosa", asp-route-id="Veg" d.asp-controller="Veg", asp-action="Foods", asp-route-id="Samosa"
b.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 Xa.asp-controller b.asp-for c.asp-items Xd.asp-action
b.asp-for
You can pass a model to a view by a.using the Model.BindView() method b.passing a model object as an argument to the View() method inside an action method and returning the resulting object c.instantiating a View object directly within a model constructor d.creating the model entirely inside the view
b.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 a.storing it in the ViewData property and returning that property b.passing it to the View() method and returning the result c.storing it in the ViewBag property and returning that property d.passing it to the RedirectToAction() method and returning the result
b.passing it to the View() method and returning the result
To nest one layout inside another, the containing layout should a. use the @model directive Xb. always be named _ContainingLayout c. set its Layout property to the nested layout d. duplicate all of the code of the nested layout
c. set its Layout property to the nested layout
What is the following URL an example of? https://www.murach.com/shop-books/all a.A relative URL b.A tag helper c.An absolute URL d.A domain expression
c.An absolute URL
Which of the following is NOT a subclass of ActionResult? a.ViewResult Xb.EmptyResult c.PDFResult d.JsonResult
c.PDFResult
The TempData dictionary is often used with the a.Chain-of-responsibility pattern b.React pattern c.PRG pattern d.Test-driven pattern
c.PRG pattern
If you're using the default route, which action does the following URL call? https:/localhost:5001/ a.The List action of the Customer controller b.The Index action of the Customer controller c.The Index action of the Home controller d.The List action of the Home controller
c.The Index action of the Home controller
Given a controller named FoodController with an action method Burgers(), the corresponding view would be mapped by default to a.Views/Shared/Food.cs b.Views/Burgers/Food.cs c.Views/Food/Burgers.cs d.Views/Home/Burgers.cs
c.Views/Food/Burgers.cs
When you use attribute routing, the route specified by the attribute a.can't use the [controller] or [action] tokens b.can't use a question mark (?) to specify optional segments c.overrides any routes that are specified in the Startup.cs file d.can't use static segments
c.overrides any routes that are specified in the Startup.cs file
If your app uses routes with the following patterns, which route do you need to code first in the Startup.cs file? Xa.{controller=Home}/{action=Index}/{id?} Xb.{controller}/{action}/{category}/page{page} c.{controller}/{action}/{category}/page{page}/sort-by-{sortby}
c.{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. a.@foreach - RenderBody() b.@model - RenderBody() c.@render - RenderSection() d.@section - RenderSection()
d.@section - RenderSection()
What does the following code represent? @{ string myName = "John";ViewBag.Name = myName;} a.A Razor foreach loop b.A Razor expression c.A Razor if statement d.A Razor code block
d.A Razor code block