Using Data Annotations to validate fields from an HTML page and Web API

Asked

Viewed 1,165 times

4

Someone has an example of how to create a field validation in an HTML page using Data Annotation, Web API and C#.

In MVC with you, this is easily achieved by using Wizard when creating a View.

  • understand that when using Webapi you will only work with receiving and sending json, the validation of Dataannotation is valid, because MVC is the one that yields its inputs, in the case of Webapi, the most interesting, would be you return a JSON with the errors that will be in Modelstate and then you send them by View

  • Ah, just a detail, you CAN use data Annotation yes, don’t misunderstand, however it’s like I explained above =)

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.