IIS doesn't recognise view model annotations IIS doesn't recognise view model annotations asp.net asp.net

IIS doesn't recognise view model annotations


In your example you have the following property on your Model.

[Required(ErrorMessage="Your Name Required")][Display(Name = "Your Name")][DataType(DataType.Text)][MaxLength(120, ErrorMessage = "Must be under 120 characters")]                public String  YourName { get; set; }

So, the property "YourName" should get a label of "Your Name".

In your view, though, you aren't displaying the YourName property.

@Html.LabelFor(model => model.FromName)@Html.EditorFor(model => model.FromName)  

So you need to add similar attributes to your FromName property.


MVC3 supports the [StringLength] attribute, while [MinLenght] and [MaxLength] come with Entity Framework.Could you try this instead of MaxLength?

[StringLength(120, ErrorMessage = "Must be under 120 characters")]  


I'm very new to razor but I thought DisplayTextFor didn't give you a label.Wouldn't @Html.LabelFor() make more sense?