Microsoft MVC Framework Test

1. Bundling and minification are two techniques you can use in ASP.NET 4.5 to:
Answers:
• Reduce the number of requests to the server
• All of these
• Reduce the size of requested assets
• Improve request load time
2. As a best practice, all input validation should occur in which layer?
Answers:
• Model
• Controller
• View
• This is not best practice
3. Which of these formats is not supported out of the box by Web API?
Answers:
• JSON
• XML
• Form URL-encoded
• AMF
4. Which of these are NOT advantages to the ASP.NET MVC framework?
Answers:
• It does not use view state or server-based forms, giving full control over the behavior of an application.
• It provides better support for test-driven development.
• All are advantages
• It makes it easier to manage complexity by dividing an application into the model, the view, and the controller.
5. Which symbol[s] is used to designate Razor syntax code in a .cshtml file?
Answers:
• @
• ~
• <%
• ||
6. What does MVC stand for?
Answers:
• Model View Controller
• Pattern
• View Controller Model
• Model View Configuration
• Model
7. The MVC framework is defined in which namespace?
Answers:
• Model.View.Controller
• SQL.Java.CSS
• Unit.Control.Microsoft
• System.Web.Mvc
8. True or False? It is best practice to use model binding instead of manually parsing the request.
Answers:
• True
• False
9. Which base class can be used for the return value of a MVC action method?
Answers:
• ActionResult
• Result
• ControllerResult
• HttpResult
10. When creating a data-entry view for new data, which two HTTP request verbs (methods) should you anticipate using to serve the form to the user and allow the user to submit the form?
Answers:
• PATCH, TRACE
• CONNECT, PUT
• GET, POST
• POST, PUT
11. True or False: By default, all controller classes must be named by using the "Controller" suffix.
Answers:
• True
• False
12. How can you restrict access to a Controller action so that only authorized users can call that action?
Answers:
• Authorize attribute
• SecurityDemand attribute
• AllowUsers attribute
• A call to SecurityDemand static class
13. What is the default view engine that comes with MVC3?
Answers:
• Aspx
• Spark
• Razor
14. Which of these emulators are valid mobile emulators for MVC applications?
Answers:
• Windows 7 Phone Emulator
• Opera Mobile Emulator
• All of these
• Apple Safari
15. Which Razor construct is used to indicate a view is strongly-typed
Answers:
• @type
• @model
• @context
• @entity
16. Which attribute could you use if you had a Phone Number property on your model and you wanted to validate the value against the United States phone format?
Answers:
• RegularExpression
• Required
• Custom
• Format
17. In MVC, Which represents data that you want to have displayed on viewpage?
Answers:
• Data Model
• View Model
• Domain Model
• Json Model
18. Which HTML Helper would you use to create a form element in a View?
Answers:
• Form
• FormGenerate
• FormBegin
• BeginForm
19. A controller action can return:
Answers:
• All answers are correct.
• JavascriptResult
• ContentResult
• ViewResult
20. What is the core process of rolling up a number of distinct resources together into a single downloadable resource in ASP.NET MVC?
Answers:
• Hashing
• Compacting
• Joining
• Merging
• Bundling
21. Where is data validation done?
Answers:
• Model
• Controller
• View
22. How do you prevent routing?
Answers:
• Use authentication flag in web.config
• Use deleteroute method
• Use ignoreroute method
23. What is the first filter run in a controller action?
Answers:
• Action
• None of these
• Authorization
• Result
24. You are developing an ASP.NET MVC application that displays stock market information. The stock market information updates frequently and must be displayed in real-time. You need to eliminate unnecessary header data, minimize latency, and transmit data over a full-duplex connection. What should you do?
Answers:
• Configure polling from the browser.
• instantiate a MessageChannel object on the client.
• Implement WebSockets protocol on the client and the server.
• Implement long-running HTTP requests.
25. Which of the following protocols are not supported by WCF?
Answers:
• NAMED PIPES FOR ON MACHINE COMMUNICATIONS
• HTTP
• TCP /IP
• PEER TO PEER PROTOCOLS
• All of these choices are supported by WCF
26. Which attribute could you use if you had a string property on your Model class named FirstName, but you want the labels for this property in your view to use the text "First Name"?
Answers:
• Display
• Label
• Format
• Text
27. Which namespace contains the attributes used to describe your model and it's properties?
Answers:
• System.Web
• System.Web.Mvc
• System.Annotations
• System.ComponentModel.DataAnnotations
28. If you have restricted a Controller so that all actions require the user to be authorized, how can you indicate that a specific action should be available without authorization?
Answers:
• A call to Anonymous static class
• AllowUsers attribute
• Authorize attribute
• AllowAnonymous attribute
29. How can you specify that a particular View should not use any implicitly set Layout View?
Answers:
• Rename your View to _ViewStart.cshtml
• Set the Layout property to null
• Append "None" to the name of the View
• Set the ViewBag.LayoutFile property to null
30. What attribute is used to restrict access by callers to an action method?
Answers:
• AdminOnlyAttribute
• AllowAttribute
• AuthorizeAttribute
• RestrictAccessAttribute
• AuthenticateAttrbitue
31. How is a model passed to a controller action validated?
Answers:
• ModelState.IsValid
• State.IsValid
• Model.IsValid
• StateModel.IsValid
• StateManager.IsValid
32. You are developing an ASP.NET MVC application. You need to authenticate clients by using NT LAN Manager (NTLM). Which authentication method should you implement?
Answers:
• Forms
• Windows
• Basic
• Kerberos
33. Which class represents the result of a HTTP call to the Web API framework?
Answers:
• HttpRequestMessage
• ResponseMessage
• HttpResponseMessage
• RequestMessage
34. Which is true about ModelState?
Answers:
• It has the model properties and filters
• It has the properties that have changed only
• It has the state of the model
35. What enum represents a strongly-typed collection of the HTTP Status Codes?
Answers:
• HttpStatus
• StatusCode
• HttpStatusCode
• Status
36. If you wanted to use a partial view but also pass the same model object from the parent view, what HTML Helper would you use?
Answers:
• Html.Partial()
• Html.PartialWithModel()
• Html.Action()
• Html.ActionWithModel()
37. Which class represents an initial HTTP class to the Web API framework?
Answers:
• ResponseMessage
• RequestMessage
• HttpResponseMessage
• HttpRequestMessage
38. What is the type of the ViewBag property?
Answers:
• Object
• List
• Dynamic
• IEnumerable
• Generic
39. If you wish to include custom transformation logic in your Bundles, which interface could you implement?
Answers:
• Ibundle
• IBundleInvoker
• IBundleTransform
• Itransform
40. If you have a _Layout.cshtml file in your shared views, which file can you create to have  custom layout for mobile platforms?
Answers:
• _Layout.device.cshtml
• _Layout.mobile.cshtml
• _Layout.mob.cshtml
• _Layout_mobile.cshtml
41. What property could you set on the OutputCache attribute to indicate that you want it to instantiate new caches for different combinations of parameters to the Controller action method?
Answers:
• VaryByParam
• VaryByBinding
• VaryByCustom
• VaryByAction
42. To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as?
Answers:
• Shared Folders
• Content
• Views
• Sections
• Areas
43. [WebMethod] Attribute is required when calling an MVC Action with AJAX
Answers:
• True
• False
44. If you wish to create a Web API controller, what class would you derive your controller from?
Answers:
• WebController
• ApiController
• WebApiController
• Controller
45. Which class is NOT a child of ActionResult?
Answers:
• JavaScriptResult
• RedirectToRouteResult
• JsonResult
• HttpStatusCodeResult
• CssResult
46. You are writing an action method called AddProduct inside the Product controller. The logic in your code indicates that you need to call the Cart controller’s Add method as a result of your controller’s action method. Which line of code would accomplish this?
Answers:
• return View("Cart.Add")
• Response.Redirect("Cart.aspx?Add")
• return redirect("Cart/Add")
47. Tempdata is used to:
Answers:
• pass data from controller action to the view
• pass data from the view to the controller action
• pass data between two consecutive requests
48. Which class would you return from a Controller action when performing partial page updates?
Answers:
• PartialResult
• ActionResult
• ViewResult
• PartialViewResult
49. What is OutputCacheAttribute used for?
Answers:
• To skip method execution until cached output expires.
• To mark an action method whose output will be cached.
• None of the answers
• To notify client browser that output shall be cached.
50. What attribute is used to handle an exception that is thrown by an action method?
Answers:
• IgnoreExceptionAttribute
• HandleErrorAttribute
• IgnoreErrorAttribute
• CatchErrorAttribute
• ValidateExceptionAttribute
51. ActionResult is:
Answers:
• None of these
• An interface
• An abstract class
• A container class
52. If you wish to leverage the OData standards for querying your REST service, what attribute could you use on your ApiController action?
Answers:
• OData
• Filterable
• Queryable
• Query
53. Which of these is NOT an view engine for MVC?
Answers:
• Angular
• NHaml
• NDjango
• ASPX
54. If you wish to genrate links to related resources to add hypermedia to your REST service, what class could you use?
Answers:
• UrlHelper
• Uri
• UriContext
• UrlGenerator
55. MVC Filters can only be applied to Actions
Answers:
• False
• True
56. If you wish for a ApiController action to be used for many different HTTP Verbs, which attribute would you set?
Answers:
• HttpGet
• HttpVerbs
• ActionName
• AcceptVerbs
57. You are developing an ASP.NET MVC application. The application is deployed in a web farm and is accessed by many users. The application must handle web server failures gracefully. The servers in the farm must share the short-term state information. You need to persist the application state during the session. What should you implement?
Answers:
• A state server
• A local database
• Profile properties
• ASP.NET session state
58. If you wish to use a custom IoC container when the ASP.NET MVC engine is generating instances of your controller, what interface would you implement?
Answers:
• IDependencyResolver
• IControllerActionInvoker
• Icontainer
• IInversionOfControl
59. What class would you derive from if you wish to create a custom  type for Web API's HTTP Content Negotiation?
Answers:
• MediaFormatter
• MediaTypeFormat
• TypeFormatter
• MediaTypeFormatter
60. If you want to setup custom configuration for a controller (formatters, model binders, etc.) which interface would you attribute need to implement?
Answers:
• IConfiguration
• IController
• IControllerSettings
• IControllerConfiguration
61. You are developing an ASP.NET MVC application that will be deployed on a web farm.  Passwords must be stored in the web.config file and must not be readable or in a format that is easily decodable You need to encrypt the passwords that are stored in the web.config file. Which command-line tool should you use?
Answers:
• EdmGen.exe
• Aspnet_regiis.exe
• Ngen.exe
• Aspnet_merge.exe
62. If you wish to write a module for your own custom logging or message headers, which interface could you implement?
Answers:
• IHttpModule
• IHandlerModule
• IHttpHandler
• IModule
63. Which of the following is NOT a way to pass information from a controller to a view in ASP.NET MVC 3?
Answers:
• Using a dynamic type.
• Using the ViewBag.
• Using a strongly typed model object.
• Using a JSON object.
64. Which class could you use to create rules for using custom display modes?
Answers:
• DisplayMode
• DisplayModeInstance
• DisplayInstance
• DisplayModeProvider
65. Which of these are NOT conditions in which it's recommended to use asynchronous methods?
Answers:
• The operations are simple or short-running.
• The operations are network-bound or I/O-bound instead of CPU-bound.
• Parallelism is more important than simplicity of code.
• You want to provide a mechanism that lets users cancel a long-running request.
66. RenderAction method is used to:
Answers:
• Render a partial view
• Run a controller action
• Return a ViewResult
67. What is ChildActionOnlyAttribute?
Answers:
• When click on a link entry in the list there is a partial page refresh as the new page is loaded.
• Any method that is marked with ChildActionOnlyAttribute can be called only with the Action or RenderAction HTML extension methods.
• It provides an extension attribute to check if an request is an Ajax Request for partial HTML.
• Restrict access in such a way that only ajax requests can call the action. Other actions will get a 404, which effectively means the action will never be indexed by search engine crawlers, for one.
• The ChildActionOnly attribute ensures that an action method can be called only as a child method from within a controller.
68. Which class is used by the MVC pipeline to call a resolved controller's action as the result of a HTTP request?
Answers:
• ControllerInvoker
• ActionInvoker
• ControllerActionInvoker
• RequestInvoker
69. Any method that is decorated with ChildActionOnlyAttribute can be called ONLY using:
Answers:
• Html.RenderChildAction
• $.ajax, $.get, or $.post
• Html.Action or Html.RenderAction
• Html.RenderPartial
• Url.Action or Url.ActionNew
70. When you implement your own Model Binder, what method do you have to implement?
Answers:
• BindController
• Bind
• BindModel
• ModelBind
71. Which static class could you use to enable OAuth support for clients such as Twitter & Facebook?
Answers:
• OAuth
• OAuthWebSecurity
• OAuthClients
• OAuthSecurity
72. How do you catch  unhandled action exceptions in a controller?
Answers:
• In global.asax
• In the overriden OnException method
• In the exception filter attribute
73. Which HTML Helper would you use if you want the MVC engine to dynamically generate a form for an entire object based upon the metadata of the object's type?
Answers:
• Html.ModelEditor()
• Html.Editor()
• Html.EditorForModel()
• Html.EditorFor()
74. How do you prevent forgery of a request?
Answers:
• Using ValidateAntiForgeryToken, Html.AntiForgeryToken helper method and the AntiForgeryActionResult.
• Using the ValidateAntiForgeryToken attribute.
• Using the Html.AntiForgeryToken helper method.
• Using ValidateAntiForgeryToken and Html.AntiForgeryToken helper method only.
• Using the AntiForgeryActionResult.
75. You are developing an ASP.NET MVC 2 application. A view contains a form that allows users to submit their first name. You need to display the value that is submitted, and you must ensure that your code avoids crosssite scripting. Which code segment should you use?
Answers:
• <%: Model.FirstName %>
• <%= Model.FirstName %>
76. Which of the following is NOT a member of the UrlHelper class.
Answers:
• Encode
• RouteUrl
• RenderAction
• IsLocalUrl
• Action
77. Which of these is a property of OutputCache attribute?
Answers:
• VaryByOrder
• VaryByNone
• VaryByHeader
• VaryByDuration
• VaryByLocation
78. What is the purpose of _ViewStart.cshtml?
Answers:
• To define the starting HTML code used by any view under its folder and subfolders.
• To register the ViewState mechanism and initialize the razor engine.
• To make it easy to apply the same logic to all the views under its folder and subfolders.
79. Where are the routing rules defined in an asp.net MVC application?
Answers:
• on View
• on Controller
• Application_Start event in Global.asax
• RegisterRoutes method in Global.asax
80. Recipe is available in:
Answers:
• MVC4
• MVC2
• MVC3
• All answers are correct
81. Which attribute could you use if you had a property on your Model class that you wish to be hidden when using the EditorForModel HTML Helper method?
Answers:
• HiddenInput
• Hidden
• Display
• DisplayValue
82. What is strongly typed?
Answers:
• Model
• ViewBag
• ViewData
• Only ViewData and Model
83. The advantage of using read-only attribute for session state is:
Answers:
• Scalability
• Parallel access of session
• Both of these
• Neither of these
84. What is the advantage of InProc Session Storage over the other built-in methods?
Answers:
• It's fast and scalable.
• It allows for distributed caching in a web-farm, because the data is separated per server.
• It lacks thread safety by eliminating locks and as a result it's very fast.
• It can store non-serialisable data.
• InProc storage has no benefits whatsoever compared to the other built-in methods.
85. What type of filter should be used if you want to modify the result of an action method?
Answers:
• Result filter
• Output filter
• Action filter
• Response filter
86. RenderPartial method:
Answers:
• Renders to the stream
• Neither answer is correct
• Return a render string
• Both answers are correct
87. Which property can you set on the BundleCollection class to indicate that you wish to enable support for CDN scripts or styles?
Answers:
• UseCdn
• UseCdnServer
• CdnEnabled
• Cdn
88. An MVC application can have a:
Answers:
• View state
• Neither session nor view state
• Both session and view state
• Session
89. An MVC Filter can only be applied as an Attribute above an Action or Controller
Answers:
• False
• True
90. Which method is NOT valid in the context of an MVC view?
Answers:
• @RenderBody();
• @RenderPage("page.html");
• @RenderSection("section");
• @RenderAction("Action")
• None of the answers
91. Which class is used by the MVC pipeline to map data from a HTTP request to the parameters in a controller's action method?
Answers:
• DefaultModelBinder
• ParameterBinder
• ModelBinder
• RouteBinder
92. You are authoring unit tests. The unit tests must test code that consumes sealed classes. You need to create, maintain, and inject dependencies in the unit tests.
Answers:
• Hard-coded implementation
• T4 text templates and code generation
• Shim types
• Stub types
93. Which class contains information about the HTTP request that is parsed and inspected by the MVC pipeline when determining which controller and action to invoke?
Answers:
• RequestContext
• Request
• HttpRequestObject
• HttpContext
94. What is the most scalable way to share Session information in a web farm?
Answers:
• AppFabric caching
• ASP.net State Server
• InProc storage
• SQL Server storage
95. What type would your Controller's action return if you wish to have an asynchronous action method that returns a View?
Answers:
• Task
• Task<ActionResult>
• AsyncActionResult
• ActionResult
96. You are developing an ASP.NET MVC application. The application must allow users to enter JavaScript in a feedback text box only. You need to disable request validation. What should you do?
Answers:
• Apply and set the CausesClientSideValidation attribute on the text box to FALSE.
• Use the HttpRequest.Unvalidated property to read the unvalidated form value.
• Apply and set the ValidateInput attribute on the text box to FALSE.
• Use the HttpRequest.Form property to read the unvalidated form value.
97. True or False? You can use routing and "web.config" files to secure your MVC application.
Answers:
• True
• False
98. ASP.NET MVC Framework implements a(n):
Answers:
• Page controller pattern
• MVC pattern
• Front controller pattern

No comments:

Post a Comment