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 7505703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:00:00+00:00 2026-05-29T22:00:00+00:00

When working with asp.net MVC 3, the default website which is installed from the

  • 0

When working with asp.net MVC 3, the default website which is installed from the template has an AccountModel. Within this, there are DataAnnotations for the password property and here the MinimumLength of the StringLength is set.

However, within the .NET framework Membership provider, you can set the minRequiredPasswordLength via the web.config file.

Now if you were to set the minRequiredPasswordLength to say 6, yet have the AccountModel.password MinimumLength set to 1, then you would not be able to register if your password is only 1 character in length. Same the other way around, minRequiredPasswordLength is 1 and MinimumLength is 6 will not allow registration.

So to me this is a bit backwards. If an installation of the app does not require the a longer password length, then you have to change this in the model.

DataAnnotations have to be constant values from what I have read, so is there a way to link these two? Ideally I would like to only have to change the value in the web.config and not have to worry about rebuilding projects.

Edit

I noticed after looking into this more that Pre MVC 3 Tools Update, the Project Template actually contained a DataAnnotation which linked the Membership minRequiredPasswordLength property from the web.config to the AccountModel
Blogged about it here: http://timjames.me/mvc-3-password-length-dataannotation

  • 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-29T22:00:02+00:00Added an answer on May 29, 2026 at 10:00 pm

    The short answer is that you can’t. DataAnnotations are statically compiled into the assembly, and cannot be changed at runtime.

    You could create a custom annotation that looked up the length, or use a remote validation to validate against the value in the web.config. But this would not be using the standard Length attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a large data entry page using the default ASP.NET MVC
After working with ASP.Net MVC, it has me thinking about Rails. I worked with
I am working on an ASP.Net MVC website and I am stuck on a
I am working on a ASP.NET MVC web site that has multiple submit buttons.
I have an asp.net mvc application, which uses the default user database. It all
I've written a web application with ASP.NET MVC. The default ControllerFactory has been replaced
I am working on a website in asp.net mvc. I have a route routes.MapRoute(
I am working with couple of friends on an ASP.NET MVC website. The project
I changed the default routing in ASP.NET MVC from routes.MapRoute( Default, // Route name
I'm working with an ASP.NET MVC site which will use a CMS controller for

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.