Thursday, October 2, 2014

ASP.NET MVC Question and Answer Part-1

Here are few ASP.NET MVC interview question and answer which are very useful to clear eLance test.

1- Recipe is available in:

A- All answers are correct
B- MVC4
C- MVC3
D- MVC2

Answer : B

2- What is strongly typed?

A- Model
B- Only ViewData and Model
C- ViewBag
D- ViewData

Answer: B


3-What is the purpose of _ViewStart.cshtml?

A- To define the starting HTML code used by any view under its folder and subfolders.
B- To make it easy to apply the same logic to all the views under its folder and subfolders.
C- To register the ViewState mechanism and initialize the razor engine.

Answer: B

4- How do you catch  unhandled action exceptions in a controller?

A- In the exception filter attribute
B- In global.asax
C- In the overriden OnException method

Answer: C


5- Which static class could you use to enable OAuth support for clients such as Twitter & Facebook?

A-OAuthClients
B-OAuth
C-OAuthSecurity
D-OAuthWebSecurity

Answer: D


6-What class would you derive from if you wish to create a custom  type for Web API's HTTP Content Negotiation?

A-MediaTypeFormat
B-MediaFormatter
C-MediaTypeFormatter
D-TypeFormatter

Answer: C


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

A-True
B-False

Answer: A

8- If you wish for a ApiController action to be used for many different HTTP Verbs, which attribute would you set?

A- AcceptVerbs
B- HttpVerbs
C- HttpGet
D- ActionName

Answer: A

9- MVC Filters can only be applied to Actions

A - True
B - False

Answer:  False

10- If you wish to genrate links to related resources to add hypermedia to your REST service, what class could you use?

A-UrlGenerator
B-UrlHelper
C-Uri
D-UriContext

Answer:  B

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

A- Query
B- Filterable
C- Queryable
D- OData

Answer: Queryable

12- ActionResult is:

A-An abstract class
B-None of these
C-A container class
D-An interface

Answer: A

13- If you wish to create a Web API controller, what class would you derive your controller from?

A-WebApiController
B-WebController
C-ApiController
D-Controller

Answer : C

14-What attribute is used to handle an exception that is thrown by an action method?

A-HandleErrorAttribute
B-ValidateExceptionAttribute
C-IgnoreErrorAttribute
D-CatchErrorAttribute
E-IgnoreExceptionAttribute

Answer :  A

15-What is OutputCacheAttribute used for?

A-None of the answers
B-To mark an action method whose output will be cached.
C-To skip method execution until cached output expires.
D-To notify client browser that output shall be cached.

Answer: B


16 -Which base class can be used for the return value of a MVC action method?

A-HttpResult
B-ActionResult
C-Result
D-ControllerResult

Answer-B

No comments:

Shared Button