我想使用 XmlFormatter 将一个类序列化为 MVC Web API 中的响应,但是在创建响应时出现以下异常:
MediaTypeFormatter formatter = Configuration.Formatters.XmlFormatter;
HttpResponseMessage resp = Request.CreateResponse<Model>(HttpStatusCode.OK, value: modelObject, formatter: formatter);
例外:
The configured formatter 'System.Web.Http.Tracing.Tracers.XmlMediaTypeFormatterTracer' cannot write an object of type 'Model'.
怎么了 ?