If you trace the requests in IE you may notice that it doesn't fire validation action method for every change. But, It fires validation method for every single change in the Firefox.
It should return 200 HTTP Code for every call but, in IE it returns 304 for the inputs which you recently worked with it. The reason is IE caches the result of requests so it returns the previous request without running validation method.
Simple fix is Adding OutputCache(Location = OutputCacheLocation.None,
NoStore = true) attribute to action method.
|
Sample:
public class
EmailModel
{
[Remote("EmailAlreadyExists", "MyController", AdditionalFields = "CurrentEmail")]
public string
Email { get; set;
}
public string
CurrentEmail { get; private
set; }
}
[OutputCache(Location = OutputCacheLocation.None,
NoStore = true)]
public ActionResult
EmailAlreadyExists(string email, string
currentEmail)
{
var
result = false;
// do something and set result
return Json(result, JsonRequestBehavior.AllowGet);
}
Reference:
http://stackoverflow.com/questions/7966726/asp-net-mvc3-remote-validation-calls-not-firing
Comments