草庐IT

XMLFormatter

全部标签

xml - ASP.NET 网络 API : XMLFormatter thinks he can write Json-objects

我有这样的方法:publicJObjectGet(intid){returnnewJObject(newJProperty("Test","Test"));}如果我请求JSON,它工作正常,但如果我请求XML,我会从WebAPI框架获得HTTP-Errorcode500(无一异常(exception))。XMLformatter似乎认为他可以编写json。我可以用它来测试:booltest=GlobalConfiguration.Configuration.Formatters.XmlFormatter.CanWriteType(typeof(JArray));booltest2=Gl