News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

Mcq Answers for MVC

01 public static void RegisterRoutes(RouteCollection routes) 
02 {
03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
05 routes.MapRoute("Default","{controller}/{action}/{id}",new { controller = "Home", action = "Index", id = "" });
06 }

You implement a controller named HomeController that includes methods with the following signatures.

public ActionResult About()
public ActionResult Index()
public ActionResult Details(int id)

You need to ensure that the About action is invoked when the root URL of the site is accessed. What should you do?

  1. At line 04 in the Global.asax.cs file, add the following line of code.

    routes.MapRoute("Default4Empty", "/", new {controller="Home", action="About"} );
    
  2. At line 04 in the Global.asax.cs file, add the following line of code.

    routes.MapRoute("Default", "", new { controller="Home", action="About"} );
    
  3. Replace line 05 in the Global.asax.cs file with the following line of code.

    routes.MapRoute(v "Default4Empty", "{controller}/{action}/{id}", new {controller="Home",  action="About", id=""} );
    
  4. Replace line 05 in the Global.asax.cs file with the following line of code.

    routes.MapRoute("Default", "{controller}/{action}", new {controller="Home", action ="About"});
    
Answer: Answer is c

01 public static void RegisterRoutes (RouteCollection routes) 
02 {
03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
05 routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
06 }

You implement a controller named HomeController that includes methods with the following signatures.

public ActionResult Index()
public ActionResult Details(int id)
public ActionResult DetailsByUsername(string username)

You need to add a route to meet the following requirements. ?The details for a user must to be displayed when a user name is entered as the path by invoking the DetailsByUsername action. ? User names can contain alphanumeric characters and underscores, and can be between 3 and 20 characters long. What should you do?

  1. Replace line 05 with the following code segment

    routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "DetailsByUsername", id = "" });
    
  2. Replace line 05 with the following code segment.

    routes.MapRoute( "Default", "{controller}/{action}/{username}", new { controller = "Home", action = "DetailsByUsername", username = "" }, new { username = @"\w{3,20}" });
    
  3. At line 04, add the following code segment.

    routes.MapRoute("Details by Username", "{username}", new { controller = "Home", action = "DetailsByUsername" }, new { username = @"\w{3,20}" });
    
  4. At line 04, add the following code segment

    routes.MapRoute("Details by Username","{id}",new { controller = "Home", action = "DetailsByUsername" }, new { id = @"\w{3,20}" });
    
Answer: Answer is c

  1. Add the ValidateAntiForgeryToken attribute to the Details action method.

  2. Add the Bind attribute to the country parameter of the Details action method. Set the attribute's Prefix property to Country.

  3. Create a class that implements the IRouteConstraint interface. Configure the default route to use this class.

  4. Create a class that implements the IRouteHandler interface. Configure the default route to use this class.

Answer: Answer is c

  1. [Authorize(Users = "")]
  2. [Authorize(Roles = "")]
  3. [Authorize(Users = "*")]
  4. [Authorize(Roles = "*")]
Answer: Answer is a, b

public ActionResult Edit(int id)
{
return View(SelectUserToEdit(id));
}
public ActionResult Edit(Person person)
{
UpdateUser(person);
return RedirectToAction("Index");
}

The first Edit action displays the user whose details are to be edited, and the second Edit action is called when the Save button on the editing form is clicked to update the user details. An exception is thrown at run time stating that the request for action Edit is ambiguous. You need to correct this error and ensure that the controller functions as expected. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

  1. Add the following attribute to the first Edit action. [AcceptVerbs(HttpVerbs.Head)]

  2. Add the following attribute to the first Edit action. [HttpGet]

  3. Add the following attribute to the second Edit action. [HttpPost]

  4. Add the following attribute to the second Edit action. [HttpPut]

Answer: Answer is b, c

  1. Add the following method to the CompanyController class.

    public ActionResult INFO ()
    {
    return View();
    }
    
  2. Add the following method to the CompanyController class.

    public ActionResult Company_Info()
    {
    return View();
    }
    
  3. Right-click the Views folder, and select View from the Add submenu to create the view for the action.

  4. Right-click inside the action method in the CompanyController class, and select Add View to create a view for the action.

Answer: Answer is a, d

  1. <%= Html.RouteLink("Test", "test_default", new {area = "test"}, null) %>
    
  2. <%= Html.ActionLink("Test", "Details", "Test",new {area = "test"}, null) %>
    
  3. <a href="<%= Html.RouteLink("Test", "test_default",new {area = "test"}, null) %>">Test</a>
  4. <a href="<%= Html.ActionLink("Test", "Details", "Test",new {area = "test"}, null) %>">Test</a>
Answer: Answer is b

01 public class Routes : AreaRegistration
02 {
03 public override string AreaName
04 {
05 get { return "product"; }
06 }
08 public override void RegisterArea(AreaRegistrationContext context)
09 {
10 context.MapRoute("product_default","product/{controller}/{action}/{id}",new { controller = "Product", action = "Index",id = "" });
11 }
12 }

When you load the URL http:///product, you discover that the correct page is not returned. You need to ensure that the correct page is returned. What should you do?

  1. Replace line 10 with the following code segment

    context.MapRoute("product_default","{area}/{controller}/{action}/{id}",new {area="product", controller = "Product", action = "Index", id = "" });
    
  2. Replace line 10 with the following code segment

    context.MapRoute("product_default","area}",new {controller = "Product", action = "Index", id = "" });
    
  3. Add the following code segmnet at line 11

    Area Rgistration.RegisterAllAreas();
    
  4. Add the following Code segmnet to the Register Routes in globel asax.cs file

    Area Rgistration.RegisterAllAreas();
    
Answer: Answer is d

  1. In the site's master page, create a div element with an ID of Navigation. Add the following code segment inside this div element.

    <% Html.RenderPartial("~/Views/Shared/MenuBar.ascx"); %>
    
  2. In the site's master page, create a div element with an ID of Navigation. Add the following code segment inside this div element.

    <%= Url.Content("~/Views/Shared/MenuBar.ascx") %>
    
  3. In each of the controller's action methods, add an entry to the ViewData collection with a key of Navigation and a value of ~/Views/Shared/MenuBar.ascx

  4. In the site's Global.asax.cs file, register a route named Navigation that points to the ~/Views/Shared/ MenuBar.ascx file.

Answer: Answer is a

public class Player
{
public String Name { get; set; }
public int LastScore { get; set; }
public int HighScore { get; set; }
}

You need to ensure that the custom formatting is applied to LastScore values when the HtmlHelper. DisplayForModel method is called for any view in the application that has a model of type Player. What should you do?

  1. Rename Score.ascx to LastScore.ascx.

  2. Move Score.ascx from the Views/Shared/DisplayTemplates folder to the Views/Player/DisplayTemplates folder.

  3. Add the following attribute to the LastScore property.
    [UIHint("Score")]

  4. Add the following attribute to the LastScore property

    [Display(Name="LastScore", ShortName="Score")]

Answer: Answer is c

Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;