Asp.net web api 无数据契约的webapi内容协商

Asp.net web api 无数据契约的webapi内容协商,asp.net-web-api,content-negotiation,Asp.net Web Api,Content Negotiation,如何使HttpResponseMessage遵循XMLSchema而不是datacontract 我试着去做 return new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new ObjectContent<Foo>(foo, Configuration.Formatters.XmlFormatter) }; 返回新的HttpResponseMessage() { St

如何使HttpResponseMessage遵循XMLSchema而不是datacontract

我试着去做

return new HttpResponseMessage()
{
     StatusCode = HttpStatusCode.OK,
     Content = new ObjectContent<Foo>(foo, Configuration.Formatters.XmlFormatter)

};
返回新的HttpResponseMessage()
{
StatusCode=HttpStatusCode.OK,
内容=新的ObjectContent(foo,Configuration.Formatters.XmlFormatter)
};
但这并没有奏效

如果我这样做,操作将始终服务于xml,而不会进行内容协商。我试图将列表添加为参数,但HttpResponseMessage不需要列表,只需要一个项目


有没有一种方法可以允许在不使用DataContract的情况下进行内容协商?基本上现在HttpResponseMessage忽略了xml模式。

我想答案是使用

GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;