title: ASP.NET Web API Serialize only public members or properties (ignore fields)
body: <p>Is there a possibility in the ASP.NET Web API to define that only public members should be serialized or that only properties should be serialized?</p>
  
  <p>The background is: We are storing the initial values for each property in a own private field (see example below). The problem now is that these fields are also serialized in our Rest Application, but that is not really useful, because this API is mainly used by external customers. It also not an option to remove the DataMember attributes, because we have also WCF services where this fields need to be serialized and transfered.</p>
  
  <pre><code>    [DataMember]
      private bool seasonNameIsInitialized;
      [DataMember]
      private string seasonName;
      [DataMember]
      private string seasonNameInitial;
  
      /// &lt;summary&gt;
      /// Season Name
      /// &lt;/summary&gt;
      [Required]
      [MaxLength(100)]
      [Display(ResourceType = typeof(ResourcesModel), Name = nameof(ResourcesModel.SeasonName))]
      [DatabaseColumn(Name = "BEZ")]
      [DataMember]
      public string SeasonName
      {
          get
          {
              return seasonName;
          }
          set
          {
              string oldSeasonName = seasonName;
              seasonName = value;
  
              if (seasonNameIsInitialized)
              {
                  OnPropertyChanged(oldSeasonName, seasonName);
              }
              else
              { 
                  seasonNameInitial = value;
                  seasonNameIsInitialized = true;
              }
          }
      }
  </code></pre>