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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:15:22+00:00 2026-05-15T01:15:22+00:00

I am currently working on an ASP.NET MVC2 project. This is the first time

  • 0

I am currently working on an ASP.NET MVC2 project. This is the first time I am working on a real MVC web application. The ASP.NET MVC website really helped me to get started really fast, but I still have some obscure knowledge concerning datamodel validation.

My problem is that I do not really know where to manage my filled datamodel when it comes to complex validation rules. For example, validating a string field with a Regex is quite easy and I know that I just have to decorate my field with a specific attribute, so data management rules are implemented in the model. But if I have multiple fields that I need to validate which each other, for example multiple datetime that need to be correctly set following a specific time rule, where do I need to validate them? I know that I could create my own validation attributes, but sometimes validation ask a specific validation path which is to complex to be validated using attributes.

This first question also leads me to a related question which is, is it right to validate a model in the controller? Because for the moment that is the only way I found for complex validation. But I find this a bit dirty and I feel it does not really fit a the controller role and much harder to test (multiple code path).

Thanks.

NB: I got some pretty good solutions here but I am waiting for other ideas and some “best practice” solution”.

  • 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-15T01:15:22+00:00Added an answer on May 15, 2026 at 1:15 am

    Mega Dupe. Mega Subjective. The “where and how to validate with MVC” argument has been beaten to death without coming up with a straight answer. This is so subjective and philosophical to each developer/shop that its almost impossible for everybody to agree on anything.

    The other issue is even the validation tooling comes in a bunch of shapes and sizes and can function in different scopes and layers. Its almost insane the variety in validation tooling. How did if( someString != “” ) get so hard? 😉

    If you read these other answers you’ll quickly find there is no best practice at all. Once you get into Domain Driven Design principals and the discussion on invalid state and objects you’ll find the discussion gets even more complicated.

    Where do you do your validation? model, controller or view

    ASP.NET MVC 2 validation using DTOs instead of domain entities

    Does ASP.Net MVC 2 validation need some more thought in terms of patterns and use?

    Mapping Validation Attributes From Domain Entity to DTO

    Which validation library for ASP.NET MVC?

    ASP.NET MVC – User Input and Service/Repository – Where to do Validation?

    ASP.NET MVC: Is Data Annotation Validation Enough?

    MVC – where to implement form validation (server-side)?

    Asp.Net MVC Validation

    DDD:

    Validation in a Domain Driven Design

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

Sidebar

Related Questions

Im working on a web project in ASP .NET MVC 2. In this project
I am currently working on another issue in my ASP.NET MVC project. In an
I'm working on an ASP.NET MVC 2 / .NET 3.5 project which includes SSRS
I'm trying to run an ASP.NET MVC 2 web application under IIS on Windows
Problem I am trying to take an existing ASP.NET web application and manually migrate
I am working through the book Professional ASP.NET MVC 2 and I am trying
So I'm currently working on rebuilding an existing website that is used internally at
This is my first question here on stack overflow. i need help on a
I'll start with appologies; I wasn't sure if this was best posted here of

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.