i have a method like this:
public JObject Get(int id)
{
return new JObject(new JProperty("Test", "Test"));
}
It works fine if I request JSON, but if I request XML i get an HTTP-Errorcode 500 from the web api framework (no exception). It seems likely that the XMLformatter thinks he can write json. I can test it with:
bool test = GlobalConfiguration.Configuration.Formatters.XmlFormatter.CanWriteType(typeof(JArray));
bool test2 = GlobalConfiguration.Configuration.Formatters.XmlFormatter.CanWriteType(typeof(JObject));
bool test3 = GlobalConfiguration.Configuration.Formatters.XmlFormatter.CanWriteType(typeof(JProperty));
bool test4 = GlobalConfiguration.Configuration.Formatters.XmlFormatter.CanWriteType(typeof(JValue));
It always returns "true". I dont want to remove the xmlformatter, but it is not acceptable that the server throws an HTTP Error 500 which I dont produce and cant solve. The best would be that the XMLformatter can serialize the object...