Answer the question
In order to leave comments, you need to log in
Three-tier ASP.NET MVC architecture. Where to validate data?
The bottom line is this, I need to implement a three-tier architecture in the project and ASP.NET MVC should act as the presentation layer. in the controller, we simply check the ModelState and, in case of an error, displays it in the view.
But in the case of a three-level architecture, as I understand it, validation should occur at the logic level (BLL), i.e. the controller must pass the data to the BLL level, then it is validated there, and in case of an error, the BLL must return some message to the controller so that it displays it in the view.
As an option, you can do a double check, i.e. at the UI level (in an MVC project) and in the BLL, then we will get rid of the problem of how to correctly display an error message to the user, but we will have to duplicate the checks because at the BLL level, the data must be validated.
Can someone explain how to implement this more correctly, and it is desirable to give any example.
Answer the question
In order to leave comments, you need to log in
At the BLL level, you validate the occurrence of values within the established boundaries and the correctness of the values,
and at the MVC level, the presence and correspondence of types.
You can check at all levels.
1) MVC controllers - FluentValidation
2) Further, everything is through contracts .
Through IoC, we wrap everything in interfaces, and then:
[ContractClass(typeof(IArrayContract))]
public interface IArray
{ контракт }
[ContractClassFor(typeof(IArray))]
internal abstract class IArrayContract : IArray
{ проверка входных и выходных параметров контрактов }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question