- MVC Framework Tutorial
- MVC Framework - Home
- MVC Framework - Introduction
- MVC Framework - Architecture
- MVC Framework - ASP.NET Forms
- MVC Framework - First Application
- MVC Framework - Folders
- MVC Framework - Models
- MVC Framework - Controllers
- MVC Framework - Views
- MVC Framework - Layouts
- MVC Framework - Routing Engine
- MVC Framework - Action Filters
- Advanced Example
- MVC Framework - Ajax Support
- MVC Framework - Bundling
- Exception Handling
- MVC Framework Useful Resources
- Questions & Answers
- MVC Framework - Quick Guide
- MVC Framework - Resources
- MVC Framework - Discussion
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.
Q 1 - .Which of the following are valid reasons for overriding the Run method? (Choose all that apply.)
C - Managing error handling for the application
D - Starting and supporting a logging application for use by the Worker role
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.)
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)
Answer : C
Explanation
C.@Html.EditorFor, in combination with @Html.ValidationMessageFor, are used for client-side validation.
Q 4 - What are common methods for detecting the type of browser running on a client? (Choose all that apply.)
A - Use JavaScript to query for the userAgent header.
B - Use the window.addEventListener method.
C - Use the viewport <meta> tag.
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?
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" });
Answer : B
Explanation
B.This is how you add an additional route and point to a different controller.
Q 6 - You work for a financial services company that deals with many small brokers. Your executives want to be able to run a report that details all the actions taken by the brokers on the site as a form of auditing and protection. Neither the application nor system currently stores this kind of information. Which of the following are viable solutions? (Choose all that apply.)
D - Override the AuthorizeAttribute and have it store the user, the URL, and the forms collection.
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.
Q 7 - You support hardware purchasing for an ASP.NET MVC application in your company. The application is finished, and the development team knows the number of intended users. Which approach will give the team the best understanding of the application's hardware needs?
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)
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")
Answer : C
Explanation
C.This will redirect to the Add method of Cart controller
Q 10 - Whichtools is used for unit testing in MVC
Answer : A
Explanation
A.MOQ are used to perform unit testing in MVC.