[HttpGet]
[HttpPost]
public HttpResponseMessage GetXml(string value)
{
var xml = $"<result><value>{value}</value></result>";
return new HttpResponseMessage
{
Content = new StringContent(xml, Encoding.UTF8, "application/xml")
};
}
I called the action using Swagger and passed this parameter 'text value'
Expected result should be an XML file like this: text value
Actual Result: strange json result without the passed value! https://www.screencast.com/t/uzcEed7ojLe
I tried the following solutions but did not work:
services.AddMvc().AddXmlDataContractSerializerFormatters();
services.AddMvc().AddXmlSerializerFormatters();
HttpResponseMessage. I also made the migration from web API -> Core and had to unlearn a lot of things like that before it started making sense to me.