here is my Register View Model
public class RegisterViewModel
{
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
public string ADI { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
[DataType(DataType.Password)]
[MinLength(6, ErrorMessage = "Parola en az 6 karakter olmalıdır!")]
public string PAROLA { get; set; }
[DataType(DataType.Password)]
[System.ComponentModel.DataAnnotations.Compare("PAROLA", ErrorMessage = "Şifre Eşleşmedi!")]
public string PAROLA_DOGRULA { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
[RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Yanlış mail,Lütfen doğru mail Giriniz")]
[Remote("IsExistEmail", "Account", ErrorMessage = "Bu email daha önce kullanımıştır")]
public string EMAIL { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
public string SOYADI { get; set; }
}
And Here is my login View Model
public class LoginViewModel
{
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
[DataType(DataType.Password)]
[Remote("CheckLoginPassword", "Account",ErrorMessage ="Girdiğiniz Email kayıtlarımızda bulunamadı.")]
public string PAROLA { get; set; }
[Required(AllowEmptyStrings = false, ErrorMessage = "Bu alanı boş bırakmayınız.")]
[RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "Yanlış mail,Lütfen doğru mail Giriniz")]
[Remote("CheckLoginMail", "Account", ErrorMessage = "Bu email daha önce kullanımıştır")]
public string EMAIL { get; set; }
}
and User View model
i use it in my view
public class UserViewModel
{
public RegisterViewModel Register { get; set; }
public LoginViewModel Login { get; set; }
}
here is my View
i use my UserViewModel
and i want to validation Form
with this Views
,its work fine but in my Controller
i have A JsonResult
Action and want to check if Email is Exist or not,Problem is when i send the email for JsonResult
action its is null
here is my View
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @id = "registerForm" }))
{
@Html.ValidationSummary(true)
@Html.ValidationMessage("RegisterErrors", new { @class = "ValidationErrorMessageColor" })
@Html.EditorFor(model => model.Register.ADI, new { htmlAttributes = new { required = "", @class = "myRegisterInput", placeholder = "Ad" } })
@Html.ValidationMessageFor(model => model.Register.ADI, "", new { @class = "ValidationErrorMessageColor" })
@Html.EditorFor(model => model.Register.SOYADI, new { htmlAttributes = new { required = "", @class = "myRegisterInput", placeholder = "Soyad" } })
@Html.ValidationMessageFor(model => model.Register.SOYADI, "", new { @class = "ValidationErrorMessageColor" })
@Html.EditorFor(model => model.Register.EMAIL, new { htmlAttributes = new { required = "", @class = "myRegisterInput", placeholder = "Email" } })
@Html.ValidationMessageFor(model => model.Register.EMAIL, "", new { @class = "ValidationErrorMessageColor" })
@Html.EditorFor(model => model.Register.PAROLA, new { htmlAttributes = new { required = "", @class = "myRegisterInput", placeholder = "Parola" } })
@Html.ValidationMessageFor(model => model.Register.PAROLA, "", new { @class = "ValidationErrorMessageColor" })
@Html.EditorFor(model => model.Register.PAROLA_DOGRULA, new { htmlAttributes = new { required = "", @class = "myRegisterInput", placeholder = "Parolayı onayla" } })
@Html.ValidationMessageFor(model => model.Register.PAROLA_DOGRULA, "", new { @class = "ValidationErrorMessageColor" })
<div class="sign-up">
<input type="submit" value="Hesap oluştur" />
</div>
}
and here is my JsonResult
Action,when i send the email it's Null
public JsonResult IsExistEmail(string email)
{
return Json(!dbContext.KULLANICIs.Any(e => e.EMAIL == email), JsonRequestBehavior.AllowGet);
}
in addition my form is on the popup modal
.