header1.html

Friday 29 November 2013

MCQs on MVC in .NET(Quiz-1)



MVC_MCQs
This Post is basicaly to fill some Coming Soon Content of Quizzes.I was planning for long time to cover MVC topic,but due to some reasons it was not happened.So today am here with some simple questions by taking some reference of MCTS 70515 exam.
Please take this Simple quiz and try to solve some more Quizzes here.
Quiz-(1):MVC 2.0 in .NET
1.If you have View with @Page directive to inherit from ViewPage<TModel> then your View is_________.(where TModel is typpe of Model)
Partial View
Strongly Typed View
Content View
Template View


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


3.You are implementing an ASP.NET MVC 2 Web application. The URL with path /Home/Details/{country} will return a page that provides information about the named country. You need to ensure that requests for this URL that contain an unrecognized country value will not be processed by the Details action of HomeController.What should you do?[REF:70-515]
Add the ValidateAntiForgeryToken attribute to the Details action method.
Add the Bind attribute to the country parameter of the Details action method. Set the attribute's Prefix property to Country.
Create a class that implements the IRouteConstraint interface. Configure the default route to use this class.
Create a class that implements the IRouteHandler interface. Configure the default route to use this class.


4.You create an ASP.NET MVC 2 Web application that contains the following controller class. public class CartController : Controller { static List products = new List(); public ActionResult Index() { return View(); }} and the Views folder of your application, you add a view page named Index.aspx that includes the following @ Page directive.<%@ Page Inherits="System.Web.Mvc.ViewPage" %> You test the application with a browser. You receive the following error message when the Index method is invoked: "The view 'Index' or its master was not found." You need to resolve the error so that the new view is displayed when the Index method is invoked.What should you do?
Create a folder named Cart inside the Views folder.Move Index.aspx to the Cart folder.
Modify the Index method by changing its signature to the following: public ActionResult Index(Cart c)
Change the name of Index.aspx file to Cart.aspx
None of above


5.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?
<% Response.Write(HttpUtility.HtmlDecode(Model.FirstName)) %>
<%: Model.FirstName %>
<%= Model.FirstName %>
Both b&c will work


6.Which of the following statement is false about MVC in .NET?
Complete control over your HTML Markup
Makes Test Driven Development (TDD) very difficult
Allows you to create SEO-friendly URLs for your site
Enables rich AJAX and jQuery integration


7.The Controller class is responsible for the following processing stages:
Locating the appropriate action method to call and validating that it can be called.
Getting the values to use as the action method's arguments.
Handling all errors that might occur during the execution of the action method.
All of the above.


8.Which Helper Method is used to return a user-defined content type.
Content
JavaScript
View
RedirectToRoute


9.Which Helper Method Returns binary output to write to the response?
Content
File
JavaScript
Json


10.Which Action Result Renders a partial view, which defines a section of a view that can be rendered inside another view?
ContentResult
RedirectResult
PartialViewResult
None of above.


Conclusion:Here we saw some simple questions about MVC like ActionResults,Basics of Routing and View.
Next post we are going to cover some tricky questions.Please take your some time to write review about the Quiz.