public class UserModel
{
public LogOnModel LogOnModel { get; private set; }
public RegisterModel RegisterModel { get; private set; }
}
in my RegisterModel I have email address like this:
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")]
[Required]
[Display(Name = "E-mail")]
[Remote("IsEmailAddressAvailable", "Validation", HttpMethod = "POST")]
public string EmailAddress { get; set; }
My validationController:
public class ValidationController : Controller
{
public JsonResult IsEmailAddressAvailable(string emailAddress)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
}
The view @Model is UserProfile, the emailAddress in ValidationController is null.
I tried to change the ValidationController to look like this with no luck:
public class ValidationController : Controller
{
public JsonResult IsEmailAddressAvailable([Bind(Include = "EmailAddress")]RegisterModel register)
{
return Json(false, JsonRequestBehavior.AllowGet);
}
}