Reputation: 20364
Prior to the asp.net 4 RC update, I had been using the WebApi for outputting XML. My model had XmlSerialization attributes [XmlElement(ElementName = "the name")]
so that I could use friendlier names.
e.g.
[XmlElement(ElementName = "Branch")]
public string site_nm { get; set; }
After the .net 4 RC update, the XML which is output ignores this.
I know that some things have changed in the WebApi, like to make a method return values based on OData protocols when returning IQueryable<T>
, you now need to add [Queryable]
to your methods.
Is there something that I need to add to make the serialization work? I have read through change notes but can't see anything.
Upvotes: 3
Views: 1313
Reputation: 81660
You need to instruct the formatter to use XmlSerializer:
GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;
The default now is the DataContractSerializer.
Upvotes: 5