nerdexam
Microsoft

70-515 · Question #35

You create a new ASP.NET MVC 2 Web application. The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.) 01 public static void…

The correct answer is C. At line 04, add the following code segment. See the full explanation below for the reasoning.

Question

You create a new ASP.NET MVC 2 Web application. The following default routes are created in the Global.asax.cs file. (Line numbers are included for reference only.) 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?

Options

  • AReplace line 05 with the following code segment.
  • BReplace line 05 with the following code segment.
  • CAt line 04, add the following code segment.
  • DAt line 04, add the following code segment.

How the community answered

(45 responses)
  • A
    11% (5)
  • B
    4% (2)
  • C
    80% (36)
  • D
    4% (2)

Community Discussion

No community discussion yet for this question.

Full 70-515 Practice