MVC model property marked required when it shouldn’t have been

I had a field in my MVC application that was just your average, ordinary, field:

public int CoasterNumber { get; set; }

When I sent the model to the controller, this field was being flagged as required, even though it didn’t have a [Required] attribute attached to it.

I was able to get around this issue by making the field a nullable int:

public int? CoasterNumber { get; set; }
Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: