我有一個簡單的登錄和註冊頁面的波紋管模型。同一模特登錄和註冊
我可以在同一個模型中使用多個動作結果嗎? 因爲在我的寄存器操作方法的ModelState.isValid = TRUE,並在登錄操作是假的......
public int PacientID { get; set; }
[RegularExpression(@"^([0-9a-zA-Z]([\+\-_\.][0-9a-zA-Z]+)*)[email protected](([0-9a-zA-Z][-\w]*[0-9a-zA-Z]*\.)+[a-zA-Z0-9]{2,3})$", ErrorMessage = "Please provide valid email")]
public string PacientEmail { get; set; }
[Required(ErrorMessage = "Please provide username", AllowEmptyStrings = false)]
public string PacientUsername { get; set; }
[Required(ErrorMessage = "Please provide Password", AllowEmptyStrings = false)]
[DataType(System.ComponentModel.DataAnnotations.DataType.Password)]
[StringLength(50, MinimumLength = 8, ErrorMessage = "Password must be 8 char long.")]
public string PacientPassword { get; set; }
[Compare("PacientPassword", ErrorMessage = "Confirm password dose not match.")]
[DataType(System.ComponentModel.DataAnnotations.DataType.Password)]
public string ConfirmPassword { get; set; }
是的我不明白爲什麼你不能這樣做 – Pseudonym 2015-04-06 12:41:28
當然你可以使用相同的模型,如果你想 – 2015-04-06 12:42:03
登錄時,用戶不需要輸入ConfirmPassword?如果是,登錄操作的「ModelState.isValid」將爲false? – kcwu 2015-04-06 12:42:39