exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 104 discussion

Actual exam question from Microsoft's 70-486
Question #: 104
Topic #: 1
[All 70-486 Questions]

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:

Show Suggested Answer Hide Answer
Suggested Answer:
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
AdLentis
Highly Voted 5 years, 7 months ago
Target 2 should be "RunLog/{action}" since the controller is RunLog. And then I'm not even talking about the "{id}" parameter which appears out of nowhere.
upvoted 33 times
advenios
5 years, 6 months ago
I second that. There is no mention of an "id" parameter in the question.
upvoted 3 times
...
Aerologic
5 years, 6 months ago
You don't map a URL to a controller name. The name of the controller is RunLog but the method (endpoint) name is GetLog.
upvoted 2 times
alex_ozr
5 years, 6 months ago
url template is "{controller}/{action}/{id}". So answer is "RunLog/{action}".
upvoted 14 times
...
...
...
kar12
Most Recent 4 years, 8 months ago
Target 2 should be "Runlog/{action} " because in default no mention for optional parameter..according to signature of route map , default should contains the optional parameter when it is passed or needed. Getlog is method name..url should starts with controller name followed by method name and optional parameter.
upvoted 3 times
elevator44
4 years, 7 months ago
Yes. "Runlog/{action}" is right. "name: GetLog" is just curveball in this question. https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/creating-custom-routes-cs
upvoted 2 times
...
...
aarset89
5 years ago
2 & 3 are the answers.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...