Feedback on ASP.NET Web API

Allow the instance of DataContractSerializer used by XmlMediaTypeFormatter to be injected/configured.

Currently, we don't really have any options for customizing the DataContractSerializer instance used to output xml. It'd be nice if we could configure/inject this without having to implement a new subtype of MediaTypeFormatter.

3 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Ian Schell shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
completed  ·  Daniel Roth responded  · 

You can use the SetSerializer(Type, XmlObjectSerializer) method to set the serializer you want to use (note that DataContractSerializer is an XmlObjectSerializer)

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Ian Schell commented  ·   ·  Flag as inappropriate

    As far as I understand, that only allows you to specify a serializer for a single type, and it doesn't automatically apply to subtypes. Is this true? If so, it won't work that well because we'd have to re-add the same serializer for all types we want to use, rather than just mapping typeof(object).

Feedback and Knowledge Base