MVC Framework Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to MVC Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : E

Explanation

E.Creating and running an application in parallel is what the Run method was designed to allow.The polling service is a good example of an activity in which the Run.method enables a process to work independently of the main role.Creating and running an application in parallel is what the Run method was designed to allow.

Q 2 - You are creating an ASP.NET MVC 4 web application that will be accessed by a large number of traditional consumers. If you need to be able to access state information on the client side in JavaScript/jQuery, where can you store it? (Choose all that apply.)

A - LocalStorage

B - QueryString

C - ViewState

D - Cookies

E - B and D both

F - All of the above

Answer : E

Explanation

E.Query string information is available across all browsers and is usable on both the client and server.Cookies can be stored for a period of time on the client and be read from either client- or server-side operations.

Q 3 - You are creating an ASP.NET MVC web application. The application must accept user input for a ProductName field. To reduce delays due to invalid entries making round trips between the client and server, user input should be validated on the client before being submitted to the server. Which code segment should you choose?

A -

@Html.LabelFor(model ⇒ model.ProductName)
@Html.EditorFor(model ⇒ model.ProductName)

B -

@Html.LabelFor(model ⇒ model.ProductName)
@Html.ValidationMessageFor (model ⇒ model.ProductName)

C -

@Html.EditorFor(model ⇒ model.ProductName)@Html.ValidationMessageFor(model⇒model.ProductName)

D -

@Html.LabelFor(model ⇒ model.ProductName)

E - C and A both

F - All of the above

Answer : C

Explanation

C.@Html.EditorFor, in combination with @Html.ValidationMessageFor, are used for client-side validation.

Answer : E

Explanation

E.Using JavaScript to query the userAgent gives you information about the type of browser being used by the client.The display mode provider performs some of the analysis of the HTTP request to try and determine what kind of browser made the request.

Q 5 - You are developing an ASP.NET MVC application. You have a set of requirements to create a help section for remote users. Your typical help scheme is help/desktop or help/mobile, so logically this section should be help/remote. The change board wants the links in the application to point to the default support site. Which code segment would you use?

A - routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}", defaults: new { controller = "Home",action = "Index", id = UrlParameter.Optional });

B - routes.MapRoute( "remote", "help/remote",new { controller = "support", action = "Index" });

C - routes.MapRoute( "remote", "help",new { controller = "support", action = "Index" });

D - routes.MapRoute( "remote", "remote/help",new { controller = "support", action = "Index" });

E - C and C both

F - All of the above

Answer : B

Explanation

B.This is how you add an additional route and point to a different controller.

Answer : E

Explanation

E.Creating a globally applied action filter enables you to save the state of every action taken by the user while logged in to your site.By creating a globally applied action filter you have ensured that every action taken by the user will be logged.

Answer : C

Explanation

C.This approach will give them an objective analysis of the amount of users a server can manage at a particular level of memory or CPU usage

Q 8 - What attribute or code snippet within a controller enables a role named Admin to access actions or code blocks after the check-in code?

A - RoleProvider.GetRolesForUser("Admin")

B - [Authorize(Roles="Admin")]

C - RoleProvider.IsUserInRole(User.Name)

D - [AuthorizeAttribute(Roles="Admin")]

E - A and B both

F - All of the above

Answer : B

Explanation

B.The Authorize attribute handles authorization on a controller and/or action basis by using the Roles= qualifier

Q 9 - 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?

A - return Content("Cart.Add")

B - Response.Redirect("Cart.aspx?Add")

C - return redirect("Cart/Add")

D - return View("Cart.Add")

E - A and D both

F - All of the above

Answer : C

Explanation

C.This will redirect to the Add method of Cart controller

Q 10 - Whichtools is used for unit testing in MVC

A - moq

B - Junit

C - xunit

D - Funit

E - C and D both

F - All of the above

Answer : A

Explanation

A.MOQ are used to perform unit testing in MVC.

mvc_framework_questions_answers.htm
Advertisements