Content negotiation selects a response representation by comparing the client’s Accept header with formats ASP.NET Core MVC can produce. JSON is the default, so an application configured only for JSON returns JSON even when the client requests XML. section 20.4.2
Configure and verify negotiation in an ASP.NET Core web service:
- Return a serializable response object rather than an Entity Framework Core entity whose interface-based navigation properties may defeat XML serialization. section 20.4.2
Requesting XML
A GET request to /api/content/object with Accept: application/xml returns Content-Type: application/xml and an XML ProductBindingTarget containing the product fields. With only JSON configured, the same request returns application/json instead.


