Elance Microsoft MVC Framework Test Answers



Bundling and minification are two techniques you can use in ASP.NET 4.5 to:
Reduce the number of requests to the server
Improve request load time
Reduce the size of requested assets
All of these


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?
return redirect("Cart/Add")
return View("Cart.Add")
Response.Redirect("Cart.aspx?Add")


If you wish to write a module for your own custom logging or message headers, which interface could you implement?
IModule
IHttpHandler
IHttpModule
IHandlerModule


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?
Icontainer
IDependencyResolver
IControllerActionInvoker
IInversionOfControl


[WebMethod] Attribute is required when calling an MVC Action with AJAX
True
False


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"?
Label
Text
Format
Display


How do you prevent routing?
Use ignoreroute method
Use authentication flag in web.config
Use deleteroute method


Which of the following regular expressions can be used as a constraint so that the route will match only when the "productId" parameter is numeric?
new { productId = Integer }
new { productId = @"\d+" }
new { productId = @"^[a-zA-Z]+$" }


Which of these formats is not supported out of the box by Web API?
Form URL-encoded
XML
AMF
JSON


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?
Format
Custom
Required
RegularExpression


Which HTML Helper would you use to create a form element in a View?
Form
BeginForm
FormBegin
FormGenerate


How can you restrict access to a Controller action so that only authorized users can call that action?
A call to SecurityDemand static class
AllowUsers attribute
SecurityDemand attribute
Authorize attribute


Which base class can be used for the return value of a MVC action method?
Result
ControllerResult
ActionResult
HttpResult


True or False? It is best practice to use model binding instead of manually parsing the request.
True
False


True or False: By default, all controller classes must be named by using the "Controller" suffix.
True
False


What is the default view engine that comes with MVC3?
Spark
Razor
Aspx


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?
POST, PUT
PATCH, TRACE
CONNECT, PUT
GET, POST


Which symbol[s] is used to designate Razor syntax code in a .cshtml file?
~
||
@
<%


The MVC framework is defined in which namespace?
SQL.Java.CSS
Model.View.Controller
Unit.Control.Microsoft
System.Web.Mvc


What does MVC stand for?
Pattern
View Controller Model
Model
Model View Configuration
Model View Controller


Which of these emulators are valid mobile emulators for MVC applications?
Apple Safari
Opera Mobile Emulator
All of these
Windows 7 Phone Emulator


Which method in the RouteCollection can be used to prevent MVC from processing specific file types?
IgnoreRoute
DoNotResolve
OmitRoute
SkipRoute
AvoidRoute


The order in which routes are defined matters.
True
False


What is the core process of rolling up a number of distinct resources together into a single downloadable resource in ASP.NET MVC?
Hashing
Joining
Merging
Bundling
Compacting


A controller action can return:
JavascriptResult
ContentResult
ViewResult
All answers are correct.


Which Razor construct is used to indicate a view is strongly-typed
@model
@context
@entity
@type


In MVC, Which represents data that you want to have displayed on viewpage?
View Model
Domain Model
Json Model
Data Model


Where is data validation done?
Model
Controller
View


Which namespace contains the attributes used to describe your model and it's properties?
System.ComponentModel.DataAnnotations
System.Annotations
System.Web.Mvc
System.Web


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?
Implement long-running HTTP requests.
instantiate a MessageChannel object on the client.
Implement WebSockets protocol on the client and the server.
Configure polling from the browser.


To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as?
Views
Shared Folders
Sections
Areas
Content


What is the first filter run in a controller action?
Action
Authorization
Result
None of these


Which of the following protocols are not supported by WCF?
All of these choices are supported by WCF
HTTP
NAMED PIPES FOR ON MACHINE COMMUNICATIONS
TCP /IP
PEER TO PEER PROTOCOLS


If you wish to include custom transformation logic in your Bundles, which interface could you implement?
IBundleInvoker
Itransform
Ibundle
IBundleTransform


What attribute is used to restrict access by callers to an action method?
AdminOnlyAttribute
AllowAttribute
AuthorizeAttribute
RestrictAccessAttribute
AuthenticateAttrbitue


What enum represents a strongly-typed collection of the HTTP Status Codes?
HttpStatusCode
StatusCode
Status
HttpStatus


How can you specify that a particular View should not use any implicitly set Layout View?
Set the ViewBag.LayoutFile property to null
Rename your View to _ViewStart.cshtml
Append "None" to the name of the View
Set the Layout property to null


Which class represents the result of a HTTP call to the Web API framework?
HttpResponseMessage
ResponseMessage
RequestMessage
HttpRequestMessage


How is a model passed to a controller action validated?
ModelState.IsValid
StateManager.IsValid
Model.IsValid
State.IsValid
StateModel.IsValid


What is the type of the ViewBag property?
Object
Generic
List
IEnumerable
Dynamic


Which is true about ModelState?
It has the properties that have changed only
It has the state of the model
It has the model properties and filters


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?
VaryByParam
VaryByBinding
VaryByCustom
VaryByAction


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?
Forms
Windows
Basic
Kerberos


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?
A call to Anonymous static class
AllowUsers attribute
AllowAnonymous attribute
Authorize attribute


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?
Html.ActionWithModel()
Html.Partial()
Html.PartialWithModel()
Html.Action()


If you have a _Layout.cshtml file in your shared views, which file can you create to have custom layout for mobile platforms?
_Layout.device.cshtml
_Layout.mobile.cshtml
_Layout_mobile.cshtml
_Layout.mob.cshtml


Which class represents an initial HTTP class to the Web API framework?
ResponseMessage
HttpRequestMessage
RequestMessage
HttpResponseMessage


What attribute is used to handle an exception that is thrown by an action method?
CatchErrorAttribute
ValidateExceptionAttribute
IgnoreErrorAttribute
IgnoreExceptionAttribute
HandleErrorAttribute


Tempdata is used to:
pass data between two consecutive requests
pass data from controller action to the view
pass data from the view to the controller action


Which class is NOT a child of ActionResult?
JsonResult
RedirectToRouteResult
CssResult
JavaScriptResult
HttpStatusCodeResult


What is OutputCacheAttribute used for?
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.


Which class would you return from a Controller action when performing partial page updates?
ViewResult
PartialViewResult
PartialResult
ActionResult


If you wish to create a Web API controller, what class would you derive your controller from?
WebController
WebApiController
Controller
ApiController


MVC Filters can only be applied to Actions
True
False


If you wish for a ApiController action to be used for many different HTTP Verbs, which attribute would you set?
ActionName
HttpVerbs
HttpGet
AcceptVerbs


As a best practice, all input validation should occur in which layer?
This is not best practice
View
Controller
Model


Which of these is NOT an view engine for MVC?
NHaml
NDjango
Angular
ASPX


If you wish to leverage the OData standards for querying your REST service, what attribute could you use on your ApiController action?
OData
Queryable
Filterable
Query


ActionResult is:
An abstract class
A container class
An interface
None of these


By default, where is TempData stored?
ViewData
Cookie
Session
ViewBag
ViewModel


Which of these are NOT conditions in which it's recommended to use asynchronous methods?
You want to provide a mechanism that lets users cancel a long-running request.
The operations are simple or short-running.
Parallelism is more important than simplicity of code.
The operations are network-bound or I/O-bound instead of CPU-bound.


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?
Profile properties
A state server
ASP.NET session state
A local database


If you wish to genrate links to related resources to add hypermedia to your REST service, what class could you use?
UrlGenerator
UrlHelper
UriContext
Uri


What class would you derive from if you wish to create a custom type for Web API's HTTP Content Negotiation?
MediaFormatter
MediaTypeFormat
MediaTypeFormatter
TypeFormatter


The UIHint attribute is used to do what?
Used on the Mode to specify the Title attribute for a generated html control.
Used on the Controller to specify custom routes.
Placed on the Controller to specify which view to load.
Used on the Model to describe style attributes to change things like color and size.
Placed on the Model to specify the custom template to render for the property.


If you want to setup custom configuration for a controller (formatters, model binders, etc.) which interface would you attribute need to implement?
IControllerSettings
IController
IControllerConfiguration
IConfiguration


What does "Remote" attribute do?
Attribute to mark action to accept Ajax calls
Action filter Attribute.
Model Data Annotation Attribute to call Ajax validation action
Attribute on controller level to allow all child actions to accepts Ajax calls.
Does not exist in ASP.NET MVC Framework


When declaring routes, what are constraints used for?
Specify the order in which the routes should be processed
Restrict the requests that match a particular route
Ensure only authorized users can access a route
Format the way the parameters are processed


Which class could you use to create rules for using custom display modes?
DisplayModeInstance
DisplayInstance
DisplayModeProvider
DisplayMode


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?
EdmGen.exe
Aspnet_merge.exe
Aspnet_regiis.exe
Ngen.exe


Which of the following is NOT a way to pass information from a controller to a view in ASP.NET MVC 3?
Using the ViewBag.
Using a dynamic type.
Using a strongly typed model object.
Using a JSON object.


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?
Html.ModelEditor()
Html.EditorForModel()
Html.Editor()
Html.EditorFor()


RenderAction method is used to:
Render a partial view
Return a ViewResult
Run a controller action


How do you catch unhandled action exceptions in a controller?
In the overriden OnException method
In global.asax
In the exception filter attribute


Which class is used by the MVC pipeline to call a resolved controller's action as the result of a HTTP request?
ControllerInvoker
ControllerActionInvoker
RequestInvoker
ActionInvoker


When you implement your own Model Binder, what method do you have to implement?
BindModel
BindController
Bind
ModelBind


Any method that is decorated with ChildActionOnlyAttribute can be called ONLY using:
Html.Action or Html.RenderAction
$.ajax, $.get, or $.post
Url.Action or Url.ActionNew
Html.RenderChildAction
Html.RenderPartial


How do you prevent forgery of a request?
Using the Html.AntiForgeryToken helper method.
Using ValidateAntiForgeryToken and Html.AntiForgeryToken helper method only.
Using the ValidateAntiForgeryToken attribute.
Using the AntiForgeryActionResult.
Using ValidateAntiForgeryToken, Html.AntiForgeryToken helper method and the AntiForgeryActionResult.


What is ChildActionOnlyAttribute?
It provides an extension attribute to check if an request is an Ajax Request for partial HTML.
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.
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.


Which static class could you use to enable OAuth support for clients such as Twitter & Facebook?
OAuthSecurity
OAuthWebSecurity
OAuth
OAuthClients


Which of the following is NOT a member of the UrlHelper class.
IsLocalUrl
RouteUrl
Encode
Action
RenderAction


An MVC application can have a:
Session
View state
Both session and view state
Neither session nor view state


Recipe is available in:
All answers are correct
MVC2
MVC3
MVC4


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?
Display
Hidden
DisplayValue
HiddenInput


Where are the routing rules defined in an asp.net MVC application?
on View
on Controller
RegisterRoutes method in Global.asax
Application_Start event in Global.asax


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?
<%: Model.FirstName %>
<%= Model.FirstName %>


What is the purpose of _ViewStart.cshtml?
To make it easy to apply the same logic to all the views under its folder and subfolders.
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.


What type of filter should be used if you want to modify the result of an action method?
Action filter
Output filter
Response filter
Result filter


What is strongly typed?
ViewData
ViewBag
Only ViewData and Model
Model


Which of these is a property of OutputCache attribute?
VaryByDuration
VaryByHeader
VaryByOrder
VaryByNone
VaryByLocation


Which property can you set on the BundleCollection class to indicate that you wish to enable support for CDN scripts or styles?
CdnEnabled
Cdn
UseCdn
UseCdnServer


An MVC Filter can only be applied as an Attribute above an Action or Controller
True
False


The advantage of using read-only attribute for session state is:
Parallel access of session
Scalability
Neither of these
Both of these


What is the advantage of InProc Session Storage over the other built-in methods?
It can store non-serialisable data.
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's fast and scalable.
InProc storage has no benefits whatsoever compared to the other built-in methods.


RenderPartial method:
Both answers are correct
Return a render string
Neither answer is correct
Renders to the stream


Which class is used by the MVC pipeline to map data from a HTTP request to the parameters in a controller's action method?
DefaultModelBinder
ParameterBinder
ModelBinder
RouteBinder


Which method is NOT valid in the context of an MVC view?
@RenderBody();
@RenderSection("section");
None of the answers
@RenderAction("Action")
@RenderPage("page.html");


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.
Stub types
T4 text templates and code generation
Shim types
Hard-coded implementation


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?
RequestContext
HttpContext
HttpRequestObject
Request


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?
Apply and set the CausesClientSideValidation attribute on the text box to FALSE.
Use the HttpRequest.Unvalidated property to read the unvalidated form value.
Use the HttpRequest.Form property to read the unvalidated form value.
Apply and set the ValidateInput attribute on the text box to FALSE.


What is the most scalable way to share Session information in a web farm?
AppFabric caching
SQL Server storage
ASP.net State Server
InProc storage


What type would your Controller's action return if you wish to have an asynchronous action method that returns a View?
Task
AsyncActionResult
ActionResult
Task<ActionResult>


True or False? You can use routing and "web.config" files to secure your MVC application.
True
False


ASP.NET MVC Framework implements a(n):
MVC pattern
Page controller pattern
Front controller pattern