Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:46:18+00:00 2026-05-23T06:46:18+00:00

I have a basic MVC view model with annotations, for example: [Required(ErrorMessage=Your Name Required)]

  • 0

I have a basic MVC view model with annotations, for example:

    [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; }

I have a strongly-typed view based upon this view model. When I run the application locally, the following code generates “Your Name” label:

@Html.LabelFor(model => model.YourName)

When the application is deployed on IIS7 with .NET 4 application pool, the label says “YourName” (without a space).

This is very bizzare and I didn’t come across this before. Does anybody have an idea what might be causing this?

Cache is cleared, this has been tested from a range of web clients and result is the same.

Edit:

@model MVC.Web.Models.ContactUsModel

<div>
    @Html.LabelFor(model => model.YourName)
    @Html.EditorFor(model => model.YourName)       
</div>

Edit 2
All annotations on that field are being ignored. There are other text type fields and they have the same issue. This is happening only on a live server. Live server is IIS 7 which has been configured over Plesk 10.2. Wondering whether this is a bug since I’m using MVC 3 RTM.

Edit 3
Within the same view model I have the Email property:

    [Required(ErrorMessage = "Your Email Is Required")]
    [Display(Name = "Your Email")]
    [RegularExpression(@"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$", ErrorMessage = "Your Email Is Invalid")]
    [DataType(DataType.Text)]
    public String FromEmail { get; set; }

This property is used within a view:

    <div>
        @Html.LabelFor(model => model.FromEmail)    
        @Html.EditorFor(model => model.FromEmail)        
    </div>

But it works perfectly fine 🙁 So the email property works fine in both live and dev environment. Other properties work only in dev environment.

Edit 4
Removing MaxLength and MinLength annotations fixed the problem. I would still like to use MaxLength and MinLength annotations as part of my model validation routines though.

[MinLength(3, ErrorMessage = "Minimum 3 Characters")]
[MaxLength(30, ErrorMessage = "Maximum 30 Characters")]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:46:18+00:00Added an answer on May 23, 2026 at 6:46 am

    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")]  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic model in which i have specified some of the fields
I have a basic ActiveRecord model in which i have two fields that i
I have a basic C# console application that reads a text file (CSV format)
I have a basic MVC 2 beta app where I am trying to implement
Im new to MVC and EF. I have a basic app that lists info
I'm writing webapp using Spring 3 MVC with annotations. I use jsp for view
I have basic Single Sign-On working across 2 MVC sites (call them SiteA and
I have a basic 3 tier app Presentation/Web (ASP.NET MVC) Application Services (WCF, hosted
I have seen the ASP.NET community buzzing about MVC. I know the basics of
Currently, i have basic C++ and PHP skills. But, i want to switch to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.