My Model Class as follows:
public class Employee
{
public Guid ID { get; set; }
[Required]
[Remote("CheckName","Employee",ErrorMessage="Already Exists...!")]
public String EmployeeName { get; set; }
public String EmployeeAddress { get; set; }
[Required]
public DateTime DateOfBirth { get; set; }
public decimal Salary { get; set; }
public String Department { get; set; }
public DateTime HireDate { get; set; }
}
My Action in Controller as Follows:
[HttpGet]
public JsonResult CheckName(string Name)
{
return Json(Name.Equals("MyString"), JsonRequestBehavior.AllowGet);
}
When i executed this i am getting a following exception
NullReferenceException: Object reference not set to n instance of an object
In the View, form contains a textbox and a submit button. If You are not clear with these things, please let me know to perform a remote validation.