c# - asp.net mvc avoid duplication -


i have users table in no 2 same users can exists , best way error free?

what did wrote check duplication in controller, said me it's not right thing do. said put unique on database table? have implemented on several other controllers well. ought change it?

there several places should this.

  • at database table level: use email username , mark unique constrant
  • at model validation level can check email , return validation error
  • at client side, can place code using async request check duplicate email or username in real time when user enters username in textbox

-- edit --

it suggested place 3 better validations. inconsistent data worst thing system else. because think is, correct data = quality

-- end edit --

please keep in mind validation code should placed @ model , learn how write manageable oo code can see example of mvc store front.

hope help


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -