I have the following simple Web API controller:
// GET: api/customers
[HttpGet]
public async Task Get()
{
var
The following solution worked for me nicely.
At Startup.cs
services.AddMvc()
.AddXmlSerializerFormatters()
.AddXmlDataContractSerializerFormatters();
At YourController.cs
[HttpGet]
[Route("Get")]
[Produces("application/xml")] // If you don't like to send Content-Type header
public IActionResult Get()
{
try
{
var user = _userManager.FindByNameAsync('user').Result;
if (user != null)
{
if (!_userManager.CheckPasswordAsync(user, 'password').Result)
{
return Unauthorized();
}
else
{
var result = _services.GetDataFromService(Convert.ToInt64(2), start_date, end_date);
return Ok(result);
}
}
else
{
return Unauthorized();
}
}
catch (Exception ex)
{
return Unauthorized();
}
}