Question 102


3.4.1 Question

Multiple Choice

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" }

Answer:

B
Explanation
A. Incorrect: This is a default route; it accomplishes nothing.
B. Correct: This is how you add an additional route and point to a different controller.
C. Incorrect: The URL portion of the new route does not satisfy the question being asked.
D. Incorrect: The URL portion of the new route is reversed.