1, first to understand why the server-side verification. Be aware that the information from the network is not trustworthy.
2, although the background can be verified, but there is no front-end so good experience or convenience.
3, the integration of the pros and cons, the MVC framework can help deal with these trifles.
4, understand the MVC data annotation related content.
General characteristics: Required, which refers to a validation error that is thrown by the Required attribute when the value of the property type is null or empty, such as [Required]
Stringlength, this attribute means that when the value of a property type is longer than the set value, a validation error is thrown, such as [Stringlength (160,mininumlength=3)], where the maximum length is set, and the minimum length is set.
Range, which refers to the maximum and minimum value of a value when the property type is used, such as [Range (5,30)]
Special use: Remote, which can take advantage of server-side callback functions to execute the client's validation logic. Usage such as
[Romote ("Checkusername", "account")]
public string Username{get;set;}
The controller writes the remote Checkusername code.
Public Jsonresult Checkusername (string username)
{
var result=membership.findusersbyname (username). count==0;
Return Json (Result,jsonrequestbehavior.allowget);
}
Compare, this feature is mainly used for
Data annotations and validation