How to do model validation in every method in ASP.NET Core Web API?

后端 未结 3 1364
孤城傲影
孤城傲影 2021-02-05 13:24

I am getting into ASP.NET Core 2.0 with Web API. One of my first methods are my login:

/// 
/// API endpoint to login a user
/// 
/         


        
3条回答
  •  长情又很酷
    2021-02-05 13:53

    I would Highly recommend using [ApiController] and other attributes that help ease validation in web API based projects.

    [ApiController] this attribute does all basic validation on the modal for you before it enters the method. So you only have to inspect the modal if your want to do some form of custom validation.

提交回复
热议问题