HOTSPOT - Based on the security requirements, which line of code should you insert into the WebApiConfig file? To answer, select the appropriate options in the answer area. Hot Area:
Suggested Answer:
Scenario: The Web API must only accept one data format. The MVC front-end layer and the Web API will communicate by using JSON. The most common approach to support JSON only is to clear other formatters and leave only JsonMediaTypeFormatter around. Given an instance of HttpConfiguration you'd simply clear all and re-add JsonMediaTypeFormatter: configuration.Formatters.Clear(); configuration.Formatters.Add(new JsonMediaTypeFormatter()); References: http://www.strathweb.com/2013/06/supporting-only-json-in-asp-net-web-api-the-right-way/
I think the answer is correct, but is not the full solution.
The full solution is to remove all format first before adding only Json back.
Given an instance of HttpConfiguration you'd simply clear all and re-add JsonMediaTypeFormatter: configuration.Formatters.Clear(); configuration.Formatters.Add(new JsonMediaTypeFormatter());
In https://docs.microsoft.com/de-de/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-3.1 I found
"The framework provides built-in input and output formatters for JSON and XML. "
To fullfill the security requrement that only one media type is allowed and that the communication should be by JSON it shoud be
1. Formatter
2. Remove
3.Formatters
4.JsonFormatter
This section is not available anymore. Please use the main Exam Page.70-487 Exam Questions
Log in to ExamTopics
Sign in:
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.
abalone
Highly Voted 5 years, 8 months agodosper
5 years, 8 months agosti88
Most Recent 4 years, 8 months agoUweJ
5 years, 3 months agoAlbeom
5 years, 2 months agozimzimzimma
4 years, 11 months ago