ASP.NET MVC Json Enum

Posted by IceHeat on Stack Overflow See other posts from Stack Overflow or by IceHeat
Published on 2010-06-01T10:20:08Z Indexed on 2010/06/01 10:23 UTC
Read the original article Hit count: 740

Filed under:
|
    public class Member
    {
       public string Name { get; set; }
       public Role Role { get; set; }
    }

public enum Role
{
  Plumber
}

public JsonResult GetMember()
{
Member member = new Member();
member.Name = "Joe the Plumber";
member.Role = Role.Plumber;

return Json(member);

}

The Json always resolves the enum "Role" as 0,despite its value. What is the quickest way to get the string representation?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc