title: JSON.NET - Ignore properties for serialization
body: <p>I am currently developing a ASP.NET WebAPI using JSON.NET.
  I am looking to reduce traffic and want to ignore certain properties of my models for serialization, i.e. I don't want to return them in my JSON response, but I want to accept them when they are passed to my endpoint.</p>
  
  <p><strong>Example class</strong></p>
  
  <pre><code>public class User {
  
      public int Id { get; set; }
      public string Name { get; set; }
      public string Role { get; set; }
  
  }
  </code></pre>
  
  <p><strong>Use-cases</strong></p>
  
  <ul>
  <li>I've got a POST endpoint that takes a User model as a parameter. The request contains Name and Role. Those props should be parsed into my User.</li>
  <li>I've got a GET endpoint that returns a User. I only want the response to contain Id and Name. Role should be ignored.</li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <p>When I use the JsonIgnore attribute from JSON.NET, the property is ignored entirely. It is not serialized for my response, but the prop of my User is null, when I post the JSON User to my endpoint.</p>
  
  <p>Is there a way to ignore a prop only for serialization?</p>
  
  <p>Thank you in advance!</p>