exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 35 discussion

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

You are developing an ASP.NET MVC application.
The application provides a RESTful API for third-party applications. This API updates the information for a contact by embedding the information in the URL of an
HTTP POST.
You need to save the Contact type when third-party applications use the EditContact method.
Which code segment should you use? {Each correct answer presents a complete solution. Choose all that apply.)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️
Basics of RESTful services:
REST stands for Representational State Transfer, it is a simple stateless architecture that runs over HTTPwhere each unique URL is representation of some resource. There are four basic design principles which should be followed when creating RESTful service:
✑ Use HTTP methods (verbs) explicitly and in consistent way to interact with resources (Uniform Interface), i.e. to retrieve a resource use GET, to create a resource use POST, to update a resource use PUT/PATCH, and to remove a resource use DELETE.
Etc.

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
ex
Highly Voted 5 years, 7 months ago
It's B and C. I'be just checked with parameters list in URL - B works.
upvoted 10 times
...
LAV
Highly Voted 5 years, 4 months ago
Correct answer A,B (ref.:https://www.c-sharpcorner.com/UploadFile/dacca2/understand-formcollection-in-mvc-controller/)
upvoted 10 times
tanujgyan
5 years, 1 month ago
The link doesnt match the question here
upvoted 2 times
...
...
rdhainaut
Most Recent 4 years, 5 months ago
OMG, I have read 5 times all comments to understand why D is not correct answer. In my mind but the GetValue method exists ... then I have seen that the code don t use parentheses but square bracket ... It's so deceitful ! Correct answer: B, C
upvoted 1 times
...
soats
4 years, 10 months ago
It's B&C despite the fact that documentation says you cannot deal with complex objects in URL you apparently can. I have tested it in ASP.NET template with postman and as long as the param names match the ones used in model object is fully resolved from URI in a POST request. Although this goes against restful practices as POSTS should define params in body and almost never in URL especially for complex objects.
upvoted 2 times
...
zimzimzimma
5 years ago
B and C. It explicitly says the information is hidden in the URL, so a Query String, and the default model binder uses the QueryString as one of the sources. But I agree that a POST request combined with a querystring is weird.
upvoted 3 times
...
JosepP
5 years, 1 month ago
Definitively B,C Just tested on Visual Studio. Notice that the question and answers refer to MVC controller, not WebApi controller.
upvoted 4 times
...
Dev666
5 years, 1 month ago
A and B
upvoted 2 times
...
MaMa12345
5 years, 3 months ago
C is wrong, the question explicitly state a http POST request and you got no QueryString parameters there. FormsCollection takes values from the request body. A and B are correct.
upvoted 9 times
ozner16
4 years, 8 months ago
https://stackoverflow.com/questions/611906/http-post-with-url-query-parameters-good-idea-or-not
upvoted 1 times
...
...
Darshu
5 years, 5 months ago
what is the correct answer, finally??
upvoted 1 times
Dhaval
5 years, 4 months ago
B and C
upvoted 6 times
...
...
Kayes
5 years, 6 months ago
Why is D not an answer here?
upvoted 1 times
nimmy
5 years, 5 months ago
Allathond
upvoted 2 times
...
Dhaval
5 years, 4 months ago
due to incorrect Syntax. QuaryStringValueProvider is in the key pair values which need to be accessed with below syntax.. ....GetValue("FirstName");
upvoted 2 times
...
mart123
5 years, 1 month ago
as others mentioned the syntax is wrong and the ASP can't resolve QuaryStringValueProvider as a parameter
upvoted 1 times
...
...
daniel_lobo
5 years, 8 months ago
It is only C because of the following: https://docs.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/routing-and-action-selection Parameter Bindings. A parameter binding is how Web API creates a value for a parameter. Here is the default rule for parameter binding: Simple types are taken from the URI. Complex types are taken from the request body. Simple types include all of the .NET Framework primitive types, plus DateTime, Decimal, Guid, String, and TimeSpan. For each action, at most one parameter can read the request body.
upvoted 2 times
founderDev
5 years, 4 months ago
I agree the same. d is uncorrect. it's written wrong. Correct if written as values.GetValue("asdasd");
upvoted 2 times
...
this_is_sparta
5 years, 4 months ago
C is correct. But also B: "By default, model binding gets data in the form of key-value pairs from the following sources in an HTTP request: [...] 4. Query string parameters" (see https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-3.1)
upvoted 1 times
...
mr_
5 years ago
I have just tested complex type like in the example below and it works. In my opinion correct is B & C. Please note that these two are correct only for ASP.NET MVC, not for ASP.NET Core MVC. For the latter one .QueryString member has been replaced with just .Query (which does not exist in non-core MVC). I assumed that this question is for non-core MVC, then B & C are correct IMO.
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 ...