デフォルトASP.net MVC 3インターネットアプリケーションテンプレートは、次のモデルが含まれます。それは、電子メールアドレスを求めているアカウント/登録アクションでモデルのDataTypeAttributeはMVC 3で検証を行いますか?
public class RegisterModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email address")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
を、あなたがこのフィールドに何も入力することができそうですし、それそれを受け入れる。
DataType(DataType.EmailAddress)は実際に検証をトリガーしますか?それはそうではないようです。型を検証しない場合、その目的は何ですか?
私は同じ問題を抱えていますが、解決策を見つけましたか? – J4N