Where do you do your validation? model, controller or view

后端 未结 10 855
生来不讨喜
生来不讨喜 2020-12-25 07:52

Where do you put user input validation in a web form application?

  1. View: JavaScript client side
  2. Controller: Server side language (C#...)
  3. Model
10条回答
  •  [愿得一人]
    2020-12-25 08:27

    I check in all tiers, but I'd like to note a validation trick that I use.

    I validate in the database layer, proper constraints on your model will provide automatic data integrity validation.

    This is an art that seems to be lost on most web programmers.

提交回复
热议问题