title: Serializing Multiple Enum Values in WebApi
body: <p>If I have an Enum like this: </p>
  
  <pre><code>[Flags]
  public enum EyeColor {
      All = 1,
      Brown = 2,
      Blue = 4,
      Hazel = 8,
      Green = 16
  }
  </code></pre>
  
  <p>And then return a JSON result like this: </p>
  
  <pre><code>jsonBody.EyeColor = EyeColor.Brown | EyeColor.Blue;
  </code></pre>
  
  <p>I see the following in my jsonBody on the client: </p>
  
  <pre><code>"Brown, Blue"
  </code></pre>
  
  <p>However if I send the above string to WebAPI via an EyeColor property:</p>
  
  <pre><code>var eyeColor = "Brown, Blue"
  var query = '?Index=1&amp;EyeColor=` + eyeColor;
  // send json GET request and use [FromUri] to extract
  </code></pre>
  
  <p>Serverside, I get: </p>
  
  <pre><code>dto.EyeColor: 0
  </code></pre>
  
  <p>Though if I do this: </p>
  
  <pre><code>var eyeColor = "All"
  var query = '?Index=1&amp;EyeColor=` + eyeColor;
  // send json GET request and use [FromUri] to extract
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>dto.EyeColor: All
  </code></pre>
  
  <p>So what I'm wondering is - in the event where I want to not only retrieve a string-serialized Enum from WebApi, but also send a string to represent multiple Enums that have been selected (and deserialized into multiple enums), what do I need to do?   </p>
  
  <p>My Global.asax:</p>
  
  <pre><code>        JsonSerializerSettings jSettings = new JsonSerializerSettings();
          jSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
             GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = jSettings;
  
        GlobalConfiguration.Configuration
        .Formatters
        .JsonFormatter
        .SerializerSettings
        .ContractResolver = new CamelCasePropertyNamesContractResolver();
  </code></pre>