PrepAway - Latest Free Exam Questions & Answers

which line of code should you insert into the WebApiCon…

###BeginCaseStudy###

Testlet 1
General Overview
Adventure Works Cycles is a travel agency for cycling enthusiast. In recent years, Adventure Works Cycles has
begun renting exotic cars to its clients.
You are developing a new web application that will provide Adventure Works Cycle customers with the ability to
locate and rent exotic throughout the world.
Application Overview
The web application will be hosted in Azure. The application will provide users with the ability to search for a car
by using advanced filtering options, such as the car brand, model, year, and price. All of this information will be
stored as strings and will be displayed as drop-down lists.
The brand and model lists that will be displayed on the home page of the web application will be retrieved from
Windows Communication Foundation (WCF) services hosted in the on-premises environment.
The home page will be named home.aspx and will be developed by using Microsoft ASP.NET MVC. The
business logic will be developed by using ASP.NET Web API.
The MVC front-end layer and the Web API will communicate by using JSON. The business logic will have a call
to an assembly named CarBusinessLogic.dll.
For responding, you are creating a worker role named ReportApp in Azure that will collect data from all of the
searches made by using the web application. The application will communicate with ReportApp by using
messages.
Requirements
Security Requirements
Adventure Works Cycles identifies the following security requirements for the web application:
The Web API must only accept one data format.
The CarBusinessLogic.dll assembly must be strongly-named.
Communication between the on-premises WCF service and Azure must be encrypted.
Logging Requirements
In the Web API, you plan to create a controller named CarController. Before any action in CarController is
executed, the following line of code must execute first.
Debug.WriteLine(“pre-processing logging”);
Performance Requirements
Adventure Works Cycles identifies the following performance requirements for the web application:
After the initial deployment, any changes to the business logic of the Web API must cause minimal
downtime to the web application in the production environment.
The action in the Web API that returns the car brand must be asynchronous, while all other actions must be
synchronous.
When home.aspx is displayed,the rendered page must be cached for 10 minutes.
The web application will be deployed to multiple instances.
Financial Requirements
ReportApp will shut down every night. However, data from the searches performed during the night must still be
collected.

###EndCaseStudy###

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:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
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());
http://www.strathweb.com/2013/06/supporting-only-json-in-asp-net-web-api-the-right-way/

5 Comments on “which line of code should you insert into the WebApiCon…

  1. savel says:

    I Disagree.
    Webapi defaults support both, JSON and XML.
    It should only support JSON. I can’t choose the clear option!
    So choosing tha add.json option is not a good idea (It’s allready included)
    Removing the XML option solves the situation and then it supports only JSON.

    I think it should be:
    config.Formatters.Remove(config.Formatters.XmlFormatters);

    When we use the clear function we should get this kinf off code:
    config.Formatters.Clear();
    config.Formatters.Add(new JsonMediaTypeFormatter());
    The new JsonMediaTypeFormatter() isn’t code I can chose in this question.




    11



    0

Leave a Reply