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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:46:05+00:00 2026-06-13T20:46:05+00:00

I hope this isn’t terribly subjective, but when it comes to validating business logic,

  • 0

I hope this isn’t terribly subjective, but when it comes to validating business logic, I see two paths that, unless I’m mistaken, deliver pretty much the same result:

  • Use a service layer where all validation on your models is performed (ref: http://www.asp.net/mvc/tutorials/older-versions/models-%28data%29/validating-with-a-service-layer-cs)

  • Decorate your models with Data Annotations

In the first instance, the model is a dumb container for data, and in the second, the model knows about its valid state. Above and beyond that, is there nuance between the two that I’m missing? Should one be used over the other in some instances?

Thanks,

Chris

  • 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-06-13T20:46:06+00:00Added an answer on June 13, 2026 at 8:46 pm

    In my opinion, you could keep the basic validation (required fields, regex fields, comparative fields etc…) on your Model (InputModel) with Data Annotations or Fluent Validation, and your bussiness validation in service layer. I think the Annotations is much more to create a screen validation and inputs to server side than business validation. If you keep the business at the service layer you must remember to create a ModelState Wrapper to integrate it with Asp.Net MVC, and show it on the view.

    Take a look at a samepl of ModelState Wrapper:

    public class ModelStateWrapper : IValidationDictionary
    {
       private ModelStateDictionary _modelState;
       public ModelStateWrapper(ModelStateDictionary modelState)
       {
          _modelState = modelState;
       }
    
       #region IValidationDictionary Members
    
       public void AddError(string key, string errorMessage)
       {
          _modelState.AddModelError(key, errorMessage);
       }
    
       public bool IsValid
       {
          get { return _modelState.IsValid; }
       }
    
       #endregion
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this isn't too vague, but I'm stuck on a problem that has
I hope this isn't too subjective. I can't decide between these two design opportunities.
I hope this isn't a terribly obtuse question. I notice that MySQL will let
Alright, I hope this isn't too broad a question but my curiosity got the
I hope this question isn't too general. Well, the situation is that I am
I hope this question isn't too dumb. We have many websites internally that need
I hope this question isn't too open ended, but a nudge in the right
I hope this isn't a dupe, but it's hard to boil down the problem
I hope this isn't a duplicate, but I'm not sure even how to phrase
I hope this isn't too vague a question, but here goes. I want 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.