Home » Microsoft » 70-487 v.2 » Which line of code should you insert into the WebApiConfig file?
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:
Correct Answer:
Explanation/Reference:
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/