Pulse7
7/26/2017 - 10:36 PM

enable content negotiation json and xml

enable content negotiation json and xml

services.AddMvc(options => {
                options.RespectBrowserAcceptHeader = true;
                options.Filters.Add(new ProducesAttribute("application/xml"));//default to xml
            })
            .AddXmlDataContractSerializerFormatters();
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.3" />
    [Produces("application/json")] //change default to json
    public class Greetings : Controller
    {
    }