Friday, 22 April 2016

Easy and Smart Modal Validation in Web API 2.0



Today i have written a custom ValidateFilterAttribute that will eliminate some unnessary code in API Controller and save our developing time too. We will simply try to handle all validation from one common piece of code rather then writting every single validation in a controller.
I have used OnActionExecuting(HttpActionContext actionExecutingContext) as this allows me to remove the boilerplate if (!ModelState.IsValid) return from the methods.

No comments:

Post a Comment