i have the following problem: i'm using remote validation for validate a field and now i'm trying to manage exception
public class ValidationController : Controller
{
List<string> values = new List<string>() { "AAAA", "BBBB" }; //blacklist
public JsonResult NameAllowed(string ID)
{
throw new Exception();
//return Json(!values.Contains(ID), JsonRequestBehavior.AllowGet);
}
}
but in this case the form wasn't submitted (ERROR 500 through network capturing, dev toolbar) and doesn't appear any error.
Thanks in advance
Remote validation should ONLY be used as a graphical feedback to the client that prevents the user from sending useless data to the server. You should ALWAYS have a server side validation for everything you have to validate, and if you do, well, your form will be sent but not approved, and your validation error will be displayed along with a re-rendered form with your invalid inputs.
Take client side / remote validation as a "Pre-Validation" that has 2 purpose
They should however never be used to actually validate the data.
Edit
That said, how about just writing your validation code properly, using try catches and not letting any unhandle exception slip throught?