title: ASP.Net MVC3 - why does the default support for JSON model binding fail to decode to enum types?
body: <p>I am having an issue with ASP.Net MVC3 (RC2). I'm finding that the new JSON model binding functionality, which is implicit in MVC3, does not want to deserialize to a property that has an enum type.</p>
  
  <p>Here's a sample class and enum type:</p>
  
  <pre><code>public enum MyEnum { Nothing = 0, SomeValue = 5 }
  public class MyClass
  {
      public MyEnum Value { get; set; }
      public string OtherValue { get; set; }
  }
  </code></pre>
  
  <p>Consider the following code, which successfully passes the unit test:</p>
  
  <pre><code>[TestMethod]
  public void Test()
  {
      var jss = new JavaScriptSerializer();
      var obj1 = new MyClass { Value = MyEnum.SomeValue };
      var json = jss.Serialize(obj1);
      var obj2 = jss.Deserialize&lt;MyClass&gt;(json);
      Assert.AreEqual(obj1.Value, obj2.Value);
  }
  </code></pre>
  
  <p>If I serialize <code>obj1</code> above, but then post that data to an MVC3 controller (example below) with a single parameter of type MyClass, any other properties of the object deserialize properly, but any property that is an enum type deserializes to the default (zero) value.</p>
  
  <pre><code>[HttpPost]
  public ActionResult TestAction(MyClass data)
  {
      return Content(data.Value.ToString()); // displays "Nothing"
  }
  </code></pre>
  
  <p>I've downloaded the MVC source code from codeplex but I'm stumped as to where the actual code performing the deserialization occurs, which means I can't work out what the folks at Microsoft have used to perform the deserialization and thus determine if I'm doing something wrong or if there is a workaround.</p>
  
  <p>Any suggestions would be appreciated.</p>