I have the following simple Web API controller:
// GET: api/customers
[HttpGet]
public async Task Get()
{
var
For MVC 1.1 you need to add the Package Microsoft.AspNetCore.Mvc.Formatters.Xml and edit your Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(options => { options.RespectBrowserAcceptHeader = true; })
.AddXmlSerializerFormatters()
.AddXmlDataContractSerializerFormatters();
}
Now you can set the Accept Header:
XML: application/xml
JSON: application/json