I want to serialize the class as an answer in the MVC web API using XmlFormatter, but when I create the response, I get the following exception:
MediaTypeFormatter formatter = Configuration.Formatters.XmlFormatter; HttpResponseMessage resp = Request.CreateResponse<Model>(HttpStatusCode.OK, value: modelObject, formatter: formatter);
An exception:
The configured formatter 'System.Web.Http.Tracing.Tracers.XmlMediaTypeFormatterTracer' cannot write an object of type 'Model'.
What's wrong?
source share