Enable XML Formatters in ASP.NET Core
To return XML from an ASP.NET Core Web API Controller, we can use the Produces attribute to specify the MIME ...
Return XML From ASP.NET Core Web API Controller
To return XML from an ASP.NET Core Web API Controller, we can use the Produces
attribute to specify the MIME type of the response. However, it is also possible to receive an XML response without using this attribute. By sending an Accept
header with the text/xml
value in our HTTP request, we can receive the XML response without specifying the Produces
attribute in our controller code.
So, let’s create an action that returns an XML response: