Last Updated: February 25, 2016
·
5.892K
· iondrimba

Removing Custom Validation from Class in asp.net mvc 3/4

If you need to remove a custom validation attribute from a class before saving it but you don´t have access to the class file, you can remove it at runtime.

public ActionResult Save (Type object)
{
   ModelState.Remove("objectPropertyName");

   if(ModelState.isValid)
   {           
     //continue saving procedure          
   }
   return View();
}