Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7645875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:03:31+00:00 2026-05-31T10:03:31+00:00

We are looking at converting our currently in development WCF REST API to use

  • 0

We are looking at converting our currently in development WCF REST API to use the new ASP.NET MVC 4 Web API because it simplifies a number of things. One thing I like about WCF is the ability to add a [DataMember(EmitDefaultValue=false)] attribute to data contracts so that certain values that aren’t set, will not be serialized back on JSON/XML objects.

Is there an equivalent to this function in the new ASP.NET MVC 4 Web API? I can’t seem to find anything regarding this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:03:32+00:00Added an answer on May 31, 2026 at 10:03 am

    Depending on the serialization mechanism ASP.NET Web API will use a different serializer. Currently in the beta for JSON it will use a JavaScriptSerializer and for XML it uses XmlSerializer. But there’s a UseDataContractSerializer property on the XmlMediaTypeFormatter which allows you to use the same XML serializer as in WCF (DataContractFormatter).

    I don’t think that there is an unique way by just decorating your model with some attribute to make those 2 serializer behave the same way unless writing some custom media type formatter. So one possibility is to write custom formatters for XML/JSON and swap the serializer being used to those used in WCF.

    Here’s an example of such formatter which uses JSON.Net for JSON. You could adapt it so that it uses DataContractJsonSerializer which will take into account the EmitDefaultValue property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at converting some of our complex creation code to use an IoC
I'm looking for tutorials or walkthroughs for converting DTS packages into the new SSIS
I am currently looking on converting Thu Jun 10 16:17:55 +0530 2010 to 15/06/2010
I'm looking at converting our Rails 2.3 application to correctly handle time zones (at
I'm currently employed at a small ASP.NET/MS-SQL shop. My team has noticed that a
I'm converting a bunch of foxweb programs to asp.net. Some of the functions I
We're looking for an alternative to Java web start that effectively does the same
I'm looking for some help converting as3 code to pixelbender code in an attempt
I'm looking for the mathematical expression converting a 3D coordinate (x0,y0,z0) to a 2D
I am looking into converting my OpenGL rendering code to take advantage of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.