Remove namespace in XML from ASP.NET Web API

Option 1 is to switch to using XmlSerializer in GlobalConfiguration:

config.Formatters.XmlFormatter.UseXmlSerializer = true;

Option 2 is to decorate your models with

[DataContract(Namespace="")]

(and if you do so, you’d need to decorate the members with [DataMember] attributes).

Leave a Comment