I'm using ASP.NET MVC and I have the follwoing model class:
public enum ListType
{
black,
white
}
public class ListAddSiteModel : ApiModel
{
[RequestParameter]
public ListType list { get; set; }
}
But it doesn't work the way I want. When I don't pass list parameter in the requested URL I have that list is black. But I want that if the list parameter is not black or white string then list must be null. Is it possible to write custom attribute [IsParsable] and just add it to the list property.
public class ListAddSiteModel : ApiModel
{
[RequestParameter]
[IsParsable]
public ListType list { get; set; }
}
listcannot be null as anenumis not a nullable type. You should define it aspublic ListType? listor else give ListType a default value (ListType.none) - also you should capitalize those enum and property names