I read here and here that '/' is a valid xml character.
So,I have the following Controller/Models
using System.Runtime.Serialization;
using System.Web.Http;
namespace WebApplication1.Controllers
{
public class ValuesController : ApiController
{
public Parent Get()
{
return new Parent() { Child = new Child() { Property1 = "222" } };
}
}
[DataContract(Name = "MyName", Namespace = "")]
public class Parent
{
[DataMember(Name = "Header/Footer", EmitDefaultValue = true)]
public Child Child { get; set; }
}
[DataContract(Name = "MyName", Namespace = "")]
public class Child
{
[DataMember(Name = "Property1", EmitDefaultValue = true)]
public string Property1 { get; set; }
}
}
The above GET actions returns the following (xml)
<MyName xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Part1_x002F_Part2>
<Property1>222</Property1>
</Header_x002F_Footer>
</MyName>
Can I somehow get "Part1/Part2" instead of "Part1_x002F_Part2"?
If I request the object as JSON,it works as expected