title: Using Serializable attribute on Model in WebAPI
body: <p>I have the following scenario: I am using WebAPI and returning JSON results to the consumer based on a model. I now have the additional requirement to serialize the models to base64 to be able to persist them in cache and/or use them for auditing purposes. Problem is that when I add the <code>[Serializable]</code> attribute to the model so for converting the the model to Base64, the JSON output changes as follows:</p>
  
  <p>The Model:</p>
  
  <pre><code>[Serializable]
  public class ResortModel
  {
      public int ResortKey { get; set; }
  
      public string ResortName { get; set; }
  }
  </code></pre>
  
  <p>Without the <code>[Serializable]</code> attribute the JSON output is:</p>
  
  <pre><code>{
      "ResortKey": 1,
      "ResortName": "Resort A"
  }
  </code></pre>
  
  <p>With the <code>[Serializable]</code> attribute the JSON output is:</p>
  
  <pre><code>{
      "&lt;ResortKey&gt;k__BackingField": 1,
      "&lt;ResortName&gt;k__BackingField": "Resort A"
  }
  </code></pre>
  
  <p>How would I be able to use the <code>[Serializable]</code> attribute without changing the output of the JSON?</p>