exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 124 discussion

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

DRAG DROP -
You are developing a RESTful application by using ASP.NET Web API. The application is a pet management system and implements the following method in a controller for retrieving pet data.

The method must only accept JSON data using the standard MIME type.
You need to implement a controller that saves pet data and return a properly formatted HTTP/1.1 protocol response.
You have the following code:

Which code segments should you include in Target 1, Target 2, Target 3 and Target 4 to complete the code? To answer, drag the appropriate code segment to the correct targets in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
Each correct selection is worth one point.
NOTE:
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
References:
https://docs.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/action-results

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
MaverickCalibre
Highly Voted 5 years, 6 months ago
"/api/pet/"+ pet.id
upvoted 22 times
mr_
4 years, 11 months ago
Definitely you are right. Neither 'api/get/pet' nor 'pet/get' are RESTful. URLs should be resource-oriented, not function-like.
upvoted 4 times
...
...
this_is_sparta
Highly Voted 5 years, 4 months ago
1. HttpResponseMessage<Pet> 2. "application/json" 3. HttpResponseMessage<Pet> (1. & 2. must be same) 4. "/api/pet/" + pet.Id ("PetController" as Controller-Name makes sense. "Get" is the HTTP-Method and not part of the URL-Route)
upvoted 18 times
tiger25
5 years, 4 months ago
There is not generic version of HttpResponseMessage.
upvoted 1 times
...
mr_
4 years, 11 months ago
I agree with you. IMO that is the final answer because (even if it is really tricky): * Target 1 cannot be ActionResult - it would not compile if we return HttpResponseMessage<Pet> object or HttpResponseMessage object; * Even if there is no generic version of HttpResponseMessage anymore, it used to be as I know. It has been replaced with: Request.CreateResponse<T>(params); which returns HttpResponseMessage instance; * Why not HttpMessageContent in Target 3? Because there is no constructor overload for that type that would be even close to the args in the question; * Why not ActionResult in Target 3? Because it is abstract class so it is impossible to instantiate abstract class using 'new' keyword, like in the example.
upvoted 6 times
...
...
piedro
Most Recent 4 years, 6 months ago
Target 3 cannot be: HttpResponseMessage<Pet> https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpresponsemessage.-ctor?view=net-5.0#System_Net_Http_HttpResponseMessage__ctor
upvoted 1 times
modsjunk
4 years, 5 months ago
Question is obsolete https://stackoverflow.com/questions/11427973/has-the-generic-version-of-httpresponsemessage-been-removed-from-the-asp-net-web
upvoted 2 times
...
...
kvijen
4 years, 7 months ago
I was wrong, but still not sure 3rd HttpResponseMessage<pet> 1. ActionResult 2. "application/json" 3. HttpResponseMessage<Pet> 4. "/api/pet/" + pet.Id
upvoted 1 times
...
kvijen
4 years, 7 months ago
Correct answer 1. HttpResponseMessage<Pet> 2. "application/json" 3. HttpResponseMessage<Pet> 4. "/api/pet/" + pet.Id
upvoted 2 times
...
JJuice
5 years ago
HTTP verbs are not part of the URL routing
upvoted 3 times
...
esend3
5 years, 3 months ago
This question is incorrect i think.
upvoted 4 times
...
MaverickCalibre
5 years, 6 months ago
Generic version of HttpResponseMessage has been removed, so now just mention the return type to be of type HttpresponseMessage and when actually returning the response use Request.CreateResponse<T>(params); So Target 1 should be ActionResult and provided answer is correct.
upvoted 7 times
tiger25
5 years, 4 months ago
it's a hard trick. I answered generic type.
upvoted 4 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 ...