WebAPI MVC All MCQ
WebAPI MVC All MCQ
Q1. Which web service are more complex but are easier to maintain?
A. Simple
B. RESTful
C. both
D. None of them
Answer: A
Page: 57
Q2. ASP.NET Web API creates services that deliver data from ASP.NET applications to clients over HTTP
requests is known as
A. ASP.NET services
B. HTTP web services
C. RESTful services
D. MVC services
Answer: b
Page: 57
Q3. ASP.NET Web API uses a controller and a model but what it doesn’t have?
A. HTTP
B. Model Data
C. Views
D. None
Answer: C
Page: 57
Q4. How many types of Web API client are there?
A. Two
B. Three
C. Four
D. Five
Answer: c
Page:58
Q5. Browser -based web application can be broken into ------- broad categories.
A. One
B. Two
C. Three
D. Four
Answer: b
Page:58
Q6. An alternative approach is to use a web service to mediate access to the data store from .
A. Single application
B. Multiple application
C. Both
D. None of them
Answer: b
Page:60
Q7. Which web services support just the features required for the client of a single application?
A. RESTful
B. Simple
C. HTTP
D. REST
Answer: B
Page:62
Q8. Which web services are useful for decoupling clients and the web services they consume?
A. RESTful
B. Simple
C. HTTP
D. REST
Answer: a
Page: 63
9. Which returns all of the data objects in the model
A. HTTP
B. Web services
C. REST
D. Collection URL
Answer: D
Page:65
10. Which is would return all of the data objects in the model
A. URL/api/rsvp
B. API/rsvp/url
C. RSVP/url/api
D. None of them
Answer: A
Page:65
22 July 2019
Q1. Which package is required for ASP.NET Identity?
A. Microsoft.Aspnet.Webapi
B. Microsoft.AspNet.Identity.OWIN
C. Microsoft.Owin.Host.SystemWeb
D. Microsoft.AspNet.WebApi.Owin
Answer: B, C
[Page: 72]
Q3. The Database initializers are derived from one of base classes.
A. Two
B. Three
C. Four
D. Five
Answer: B
[Page: 80]
Q4. Which one is used to dropped and re-created database every time the database context is initialized?
A. DropCreateDatabaseAlways<T>
B. DropCreateDatabaseIfModelChanges<T>
C. CreateDatabaseIfNotExists<T>
D. None
Answer: A
[Page: 80]
Q5. Which one is used to dropped and re-created database when any of the model classes are changed?
A. DropCreateDatabaseAlways<T>
B. DropCreateDatabaseIfModelChanges<T>
C. CreateDatabaseIfNotExists<T>
D. None
Answer: B
[Page: 80]
Q6. Which one is used only if the database does not already exist?
A. DropCreateDatabaseAlways<T>
B. DropCreateDatabaseIfModelChanges<T>
C. CreateDatabaseIfNotExists<T>
D. None
Answer: C
[Page: 80]
Q8. Which one is the user management system for ASP.NET applications?
A. roles
B. identity
C. userName
D. None
Answer: B
[Page: 87]
Q10. Which one Returns an enumeration of the user objects stored by the Identity system?
A. Users
B. Find()
C. Find(user, pass)
D. None
Answer: A
[Page: 91]
22 August 2019
Q1. Which are only parameters that must be set?
A. url and verb.
B. url and data.
C. data
D. options
Answer: A
[page: 134]
Q2. Which property specifies the HTTP verb for the request.?
A. url
B. verb
C. data
D. optons
Answer: B
[page: 134]
Q3. If the Ajax request is successful and passed the data from the response which callback function will be
invoked?
A. errorCallback
B. successCallback
C. options
D. verb
Answer: B
[page: 134]
Q4. If the Ajax request is unsuccessful and passed the status code and explanatory text which callback function
will be invoked?
A. errorCallback
B. successCallback
C. options
D. verb
Answer: A
[page: 134]
Q5. Which property is used to set jQuery options for a single Ajax request?
A. url
B. verb
C. data
D. options
Answer: D
[page: 134]
Q6. Which one is not The Parameters for the sendRequest Function?
A. url
B. gotError
C. data
D. options
Answer: B
[page: 134]
Q7. Which property is set to true when a request fails and false when a request succeeds?
A. error
B. gotError
C. orders
D. options
Answer: B
[page: 136]
Q8. Which one will be sent to the web service as a query string for GET requests and in the request body for
other verbs?
A. url
B. verb
C. data
D. options
Answer: C
[page: 134]
Q10. The function sets headers for all subsequent Ajax requests?
A. AjaxHeaders
B. setAjaxHeaders
C. setAjax
D. Ajax
Answer: B
[page: 134]
Chapter09:TheAnatomyofASP.NETWebAPI
22 August 2019
Q1. Which namespace defines types that represent HTTP requests and responses.?
A. System.Web.Http.Controllers.
B. System.Net.Http.
C. ystem.Web.Http.Dependencies
D. System.Web.Http.Dispatcher
Answer: B
[page: 182]
Answer: B
[page: 182]
Q3. Which namespace contains the classes that are used to validate data sent from a client?
A. System.Web.Http.Controllers.
B. System.Web.Http.Validation.
C. ystem.Web.Http.Dependencies
D. System.Web.Http.Dispatcher
Answer: B
[page: 182]
Q4. Which Context Properties are not Defined by the ApiController Class?
A. Configuration
B. ControllerContext
C. Content
D. ModelState
Answer: C
[page: 184]
Answer: C
[page: 182]
Q7. Which namespace contains classes that provide descriptions of model classes?
A. System.Web.Http.Metadata.
B. System.Net.Http.
C. System.Web.Http.Filters
D. System.Net.Http.Formatting
Answer: A
[page: 182]
Q8. which namespace contains classes responsible for creating objects and values from HTTP requests that
can be used by action methods?
A. System.Web.Http.Metadata.
B. System.Net.Http.
C. System.Web.Http.ModelBinding
D. System.Net.Http.Formatting
Answer: C
[page: 182]
Q9. Which namespace contains the Web API URL routing classes?
A. System.Web.Http.Metadata.
B. System.Web.Http.Routing.
C. System.Web.Http.ModelBinding
D. System.Net.Http.Formatting
Answer: B
[page: 183]
Q11. Which Context Properties are not Defined by the HttpRequestMessage Class?
A. Headers
B. Properties
C. Content
D. ModelState
Answer: D
[page: 184]
Q13. Which Context Properties are not Defined by the HttpRequestMessage Class?
A. Headers
B. Properties
C. Content
D. Principal
Answer: D
[page: 184]
Q14. Which class is used to provide context information about a model class during the data binding
process?
A. HttpRequestContext
B. HttpControllerDescriptor
C. ModelBindingContext
D. HttpAuthenticationContext
Answer: C
[page: 186]
Q16. Which class is used to describe an action method and is employed as part of the data binding process?
A. HttpRequestContext
B. HttpControllerDescriptor
C. ModelBindingContext
D. HttpAuthenticationContext
Answer: A
[page: 186]
Q17. Which class is used to provide context information to global exception handlers?
A. ExceptionHandlerContext
B. HttpControllerDescriptor
C. ModelBindingContext
D. HttpAuthenticationContext
Answer: A
[page: 186]
Q18. Which class is used to provide context information to global exception loggers?
A. ExceptionHandlerContext
B. HttpControllerDescriptor
C. ExceptionLoggerContext
D. HttpAuthenticationContext
Answer: C
[page: 186]
Chapter12:CreatingMediaTypeFormatters
domain.habib@gmail.com
14 July 2019
Q1. What are responsible for serializing model data so that it can be sent to the client?
A. dataType
B. Media type formatters
C. Content type formatters
D. Json type formatters
Answer: B
[Page: 246]
Q3. The MediaTypeFormatter class defines a collection, which is used by the content Negotiator.
A. ContentTypes
B. MediaTypes
C. SupportedMediaTypes
D. None
Answer: C
[Page: 247]
Q5. The MediaTypeFormatter class defines a collection, which is used by the content Negotiator.
A. Mime
B. SupportedMediaTypes
C. Headers
D. AcceptedResult
Answer: B
[Page: 247]
Q6. How many methods a custom media type formatter must implement?
A. 1
B. 2
C. 3
D. 4
Answer: B
[Page: 247
CanReadType and CanWriteType]
Q8. Which method is called by the content negotiator to see whether the formatter is able to serialize a
specific type?
A. ReadType
B. WriteType
C. CanReadType
D. CanWriteType
Answer: D
[Page: 247]
Q12. How many jQuery Ajax settings are required to configure the Accept heading?
A. 1
B. 2
C. 3
D. 4
Answer: B
[Page: 252
dataType and accept]
Q13. Which one Adds a new header to the response with the specified value?
A. Add()
B. Add(value)
C. Add(header, value)
D. Insert(value)
Answer: C
[Page: 256]
Chapter13:UsingtheBuilt-inMediaFormatters
Q2. Which formats the built-in media type formatters are responsible for serializing data?
A. the JSON Formats
B. the XML Formats
C. Both
D. None
Answer: C
Q3. Which Built-in Media Type Formatters Returns an instance of the XmlMediaTypeFormatter class, which
serializes data into the XML format?
A. FormUrlEncodedFormatter
B. XmlFormatter
C. JsonFormatter
D. None
Answer: B
Q4. Which Built-in Media Type Formatters Returns an instance of the JsonMediaTypeFormatter class, which
serializes data into the JSON format?
A. FormUrlEncodedFormatter
B. XmlFormatter
C. JsonFormatter
D. None
Answer: C
Q5. Which Built-in Media Type Formatters Returns an instance of the FormUrlEncodedMediaTypeFormatter
class, which is used to parse form data in the model binding process?
A. FormUrlEncodedFormatter
B. XmlFormatter
C. JsonFormatter
D. None
Answer: A
Q7. Which JsonMediaTypeFormatter Configuration Methods set to true, the JSON will be indented, making it
easier to read?
A. Indent
B. MaxDepth
C. UseDataContractJsonSerializer
D. SerializerSettings
Answer: A
[Page 282]
Q9. Which JsonMediaTypeFormatter Configuration Methods Gets or sets the JsonSerializerSettings object
used to configure serialization?
A. Indent
B. MaxDepth
C. UseDataContractJsonSerializer
D. SerializerSettings
Answer: D
[Page 282]
Q2. Which one is not function that the button elements invoke?
A. getAll
B. getOne
C. postOne
D. setOne
Answer: D
Page:456
Q3. How many classes coordinate the way that Web API handles HTTP requests, known
collectively as the message handlers?
A. Three
B. Four
1
C. Five
D. Six
Answer: A
Page:457
Q4. The use of the Task result and the CancellationToken parameter indicate that the method
should execute ________?
A. Normally
B. Synchronously
C. Asynchronously
D. B&C
Answer: C
Page:457
Q5. Which one is the first message handler to receive new HttpRequestMessage objects?
A. HttpRoutingDispatcher
B. IHttpController
C. IAssembliesResolver
D. HttpServer
Answer: D
Page:458
Q7. Which one is the second message handler, which creates routing data for the request?
A. HttpRoutingDispatcher
B. IAssembliesResolver
C. HttpServer
D. None of them
Answer: A
Page:458
Q9. The instructions for matching a request and for generating the routing data are collectively
known as a ________?
A. Route
2
B. Request
C. Controller
D. Collection
Answer: A
Page:460
A. Activation
B. Request
C. Controller
D. Collection
Answer: A
Page:465
3
D. To start the program
Answer: A
[Page:486]
Q9. Fixing the Controller Segment in the Custom Route in the WebApiConfig.cs File using______.
A. System.Web.Http.Api
B. System.AspNet.Http
C. System.Web.Http
4
D. System.Web.Http.AspNet.Core
Answer: C
[Page:501]
A. Name.
B. Order
C. Template
D. None of Above
Answer: A, B, C
[Ref. Page: 514]
A. Returns the Order value that will be used to sort the routes
B. Returns the data token for the route
C. Returns the set of constraints applied to the route
D. None of above.
Answer: A
[Ref. Page: 532]
A. ConstraintMap.Add
5
B. MapHttpAttributeRoutes method
C. ConstraintMap
D. MapHttpAttributeRoutes
Answer: A
[Ref. Page: 531]
A. Name.
B. Order
C. Template
D. None of Above
Answer: A, B, C
[Ref. Page: 514]
Q6. Routes can be defined with data tokens, which are expressed as …..?
A. a Dictionary<string, string>
B. a Dictionary<string>
C. a Dictionary<string, object>
D. None of above.
Answer: C
[Ref. Page:527]
A. string value
B. decimal fractions
C. a whole number
D. None of above.
Answer: C
[Ref. Page:522]
Q8. What is the score value for Variable segment with a constraint…..?
A. 2
B. 3
C. 4
D. 1
Answer: A
6
[Ref. Page:522]
Q9.which class is used to Matches a route when the segment variable contains
only true or false?
A. bool
B. alpha
C. range
D. regex
Answer: A
[Ref. Page:520]
A. :
B. ;
C. _
D. @
Answer: A
[Ref. Page:520]
Q4. Which method are the basic unit of logic used to process a request to create a result, expressed as a
standard C# method?
A. Action methods
B. Controller method
C. Response method
D. Resolver method
Answer: A
[Page: 544]
Q6. Which one Returns a collection of FilterInfo objects that describe the filters that have been applied to
the action method
A. GetFilters()
B. GetParameters()
C. ReturnType()
D. GetFilterPipeline()
Answer: D
[Page: 548]
Q7. Which one Returns the Type produced by the action method when it is executed?
A. Type
B. TypeInfo
C. ReturnType
D. TypeName
Answer: C
8
[Page: 548]
Q10. Which Action method can be used for return a specific data?
A. Get()
B. Get(int)
C. Post()
D. Post(int)
Answer: B
[Page: 550]
Q11. Which response code is used to sending “Method Not Allowed” request?
A. 400
B. 402
C. 405
D. 408
Answer: C
[Page: 551]
Q12. Which Attributes Declares that the action method supports one or more HTTP verbs
A. AcceptVerbs
B. HttpPatch
C. HttpOptions
D. HttpHead
Answer: A
[Page: 551]
Q13. Web API filters are defined through the ____________ interface.
A. IApiFilter
B. IFilter
C. IWebFilter
D. ApiFilter
Answer: B
[Page: 558]
Q14. Which filter is used to tailor the behavior of other filters in Web API Filter?
A. Action
B. Exception
C. Override
D. Execute
Answer: C
9
[Page: 558]
Q4. Which one specifies whether more than one instance of a specific filter can be used.
________________________?
A. AllowMultipleAction
B. AllowMultiple property
C. AllowMultipleMedia
D. None of the above
Answer: B
[Page:568]
10
Q5. Which Filter Type is used for IAuthenticationFilter?
A. Authentication
B. Authorization
C. Security.
D. Override
Answer: A
[Page:568]
Q8 Which one Returns a Dictionary<string, object> that maps the names of the action method
arguments to their types?
A. ModelState
B. ActionArguments
C. ActionDescriptor
D. Request
Answer: B
[Page:572]
Q9 Which one Returns an HttpActionDescriptor object that describes the action method that is
going to be invoked?
A. ActionArguments
B. ActionDescriptor
C. Request
D. RequestContext
Answer: B
[Page:572]
Q10 Which one Returns the HttpRequestContext object that provides supplementary information
about the request?
A. ActionArguments
B. ActionDescriptor
C. Request
D. RequestContext
11
Answer: D
[Page:572]
Q11 Which one Returns a ModelStateDictionary object used in the model validation process?
A. ActionArguments
B. ActionDescriptor
C. Request
D. ModelState
Answer: D
[Page:572]
Q12 Which one Returns an HttpControllerContext object that describes the controller in which the
action method is defined?
A. ControllerContext
B. ActionDescriptor
C. Request
D. ModelState
Answer: A
[Page:572]
Q16 Which one returns the HttpActionContext that ApiController passes to the
ExecuteActionFilterAsync method?
A. ActionContext
B. Exception
C. Response
12
D. Request
Answer: A
[Page:577]
Q17 Which property is set to any exception that occurs in executing the continuation task?
A. ActionContext
B. Exception
C. Response
D. Request
Answer: B
[Page:577]
Q18 Which one returns the HttpRequestMessage object associated with the response.?
A. ActionContext
B. Exception
C. Response
D. Request
Answer: D
[Page:577]
Q19 Which one returns the HttpResponseMessage object that has been generated by the
continuation task.?
A. ActionContext
B. Exception
C. Response
D. Request
Answer: C
[Page:577]
Q20 Which one provides information about the filters that apply to an action method, sorted by
scope?
A. Filter Pipeline
B. Action Pipeline
C. Action Attribute
D. Action CounterLine
Answer: A
[Page:582]
Q21 Which one returns the filter object, which implements the IFilter interface?
A. Interface
B. Instance
C. Scope
D. Action
Answer: B
[Page:583]
Q22 Which one returns the scope of the filter, expressed using a value from the FilterScope
enumeration?
A. Interface
13
B. Instance
C. Scope
D. Action
Answer: C
[Page:583]
Q24 Which one is executed for requests that target any action method defined by the controller to
which it has been applied?
A. Global
B. Instance
C. Controller
D. Action
Answer: C
[Page:585]
Q27 Which one returns true if the user has been authenticated?
A. AuthenticationType
B. Name
C. IsAuthenticated
D. Security
Answer: C
[Page:589]
Q28 Which property returns a string that specifies the type of authentication used to create the
identity?
14
A. AuthenticationType
B. Name
C. IsAuthenticated
D. Identity
Answer: D
[Page:589]
Q29 Which property is set to an implementation of the IHttpActionResult interface if the request
cannot be authenticated?
A. ErrorResult
B. Principal
C. ActionContext
D. Identity
Answer: A
[Page:593]
Q30 Which property is used to specify the IHttpActionResult that will be executed to generate the
HttpResponseMessage object for the request?
A. ErrorResult
B. Principal
C. Result
D. Identity
Answer: C
[Page:594]
15
D. AuthT
Answer: B
[Page: 600]
Q4. Which attribute we use to perform the authentication and authorization work in controllers and action
methods?
A. Auth
B. Access
C. Authorize
D. Permit
Answer: C
[Page: 600]
Q6. How many built-in filter classes are available to perform authorization without needing to implement?
A. Two
B. Three
C. Four
D. Five
Answer: A
[Page: 607]
Q7. Which one is the response code for Internal Server Error?
A. 500
B. 501
C. 504
D. 505
Answer: A
[Page: 612]
Q8. Which one allows to disable one or more filters for an action method?
A. filter
B. filter override
C. filter Invoke
D. filter action
Answer: B
[Page: 617]
16
D. Server responses
Answer: D
[Page 626]
Q3. Index was out of range. Must be non-negative and less than the size of the collection. Now,Exception
Message comes from which namespace ?
A. System.ArgumentOutOfRangeException
B. System. HttpResponseException
C. System. ExceptionType
D. System.Web.Http.ExceptionHandling
Answer: A
[Page 627]
Q4.Which one exception that does not trigger the default behavior?
A. HttpResponseException
B. IExceptionHandler
C. ExceptionHandlerContext
D. IExceptionFilter
Answer: A
[Page 627]
Q7. Which HttpError Class Property gets or sets a descriptive string, usually used to hold the message
from the exception that
the HttpError represents.?
A. ExceptionMessage
B. ExceptionType
C. InnerException
D. Message
Answer: A
[Page 630]
17
Q8. Which HttpError Class Property gets or sets the type of the exception that the HttpError represents,
expressed as a string?
A. ExceptionMessage
B. ExceptionType
C. InnerException
D. Message
Answer: B
[Page 630]
Q9. Which HttpError Class Property gets or sets an HttpError that represents a nested error?
A. ExceptionMessage
B. ExceptionType
C. InnerException
D. Message
Answer: C
[Page 630]
Q10. Which HttpError Class Property gets or sets a message intended for the client developer that
describes the error the
HttpError represents, expressed as a string.?
A. ExceptionMessage
B. ExceptionType
C. InnerException
D. MessageDetail
Answer: D
[Page 630]
Q11. Which HttpError Class Property getsor sets the user-readable message that describes the problem
the HttpError object
represents, expressed as a string.?
A. ExceptionMessage
B. ExceptionType
C. InnerException
D. Message
Answer: D
[Page 630]
Q12. Which HttpError Class Property Gets an HttpError that contains details of model validation errors?
A. ModelState
B. StackTrace
C. InnerException
D. Message
Answer: A
[Page 630]
Q13. Which HttpError Class Property Gets the stack trace for the error that the HttpError object represents,
expressed as a string?
A. ModelState
B. StackTrace
C. InnerException
D. Message
Answer: B
[Page 630]
18
Q14. To set which property, have to create a new instance of the HttpError class using the constructor that
accepts a
ModelStateDictionary object.?
A. ModelState
B. StackTrace
C. InnerException
D. Message
Answer: A
[Page 630]
Q16. To set which property, have to create a new instance of the HttpError class using the constructor that
accepts a
ModelStateDictionary object.?
A. ModelState
B. Default
C. LocalOnly
D. Message
Answer: D
[Page 635]
19
ASP.NET Web API 2 for MVC
Chapter 26: Using OWIN
Q1. The Open Web Interface for .NET (OWIN) is a standard that defines an interface for .NET web
applications?
E. Open Web Interface
F. Open Web Interface Network
G. Open Web Internet
H. Open Web Interact
Answer: A
[Page 645]
Q4. The configuration for OWIN-hosted applications is done through a class called ___?
E. Owin
F. Startup
G. Program
H. Configuration
Answer: B
[Page 648]
Q5. A self-hosted Web API application is a stand-alone process that receives and dispatches HTTP
requests without
relying on an application server?
E. receives HTTP requests
F. dispatches HTTP requests
G. Both of them
H. None of them
Answer: C
[Page 646]
20
21