Home » Microsoft » 70-486 v.2 » Which code segments should you include in Target 1 and Target 2 to map the URLs?
DRAG DROP
You need to ensure that URLs for log manipulation are mapped to the controller.
You have the following code:
Which code segments should you include in Target 1 and Target 2 to map the URLs? To answer, drag the appropriate code segments to the correct targets. Each code segment may be used once, more than once, or not at all. You need to drag the split bar between panes or scroll to view content.
Select and Place:
Correct Answer:
Explanation/Reference:
Target 1: routes.MapRoute(
The MapRoute method takes three parameters: routes, name, and URL.
Target 2: url: "GetLog/{action}/{id}", Example code: routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller ="Home", action = "Index", id = "" } // Parameter defaults
);
Incorrect:
Not routes.MapHttpRoute(:
The MapHttpRoute method takes three parameters: routes, name, and routetemplate, but we need an URL parameter, not a routeTemplate parameter.
References: https://msdn.microsoft.com/en-us/library/system.web.mvc.routecollectionextensions.maproute(v=vs.118).aspx https://msdn.microsoft.com/en-us/library/cc668201.aspx
GetLog is an action
RunLog is a controller
Getlog/{action} is invalid because it is action/action and no controller used
Correct answer is RunLog/{action}
Nothing in the question references an id – I know this is a more common default, but isn’t it better have the Controller name match, as in url: “RunLog/{action}”?