I’d need to implement the “partial validation technique” on MVC 4, as reported in this answer too:
public class DontValidateEmailAttribute : ActionFilterAttribute
{ public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var modelState = filterContext.Controller.ViewData.ModelState;
var incomingValues = filterContext.Controller.ValueProvider;
var key = modelState.Keys.Single(x => incomingValues.Equals("Email"));
modelState[key].Errors.Clear();
}
}
But I get the following compile error: “'System.Collections.Generic.ICollection<string>' does not contain a definition for 'Single' and no extension method 'Single' accepting a first argument of type 'System.Collections.Generic.ICollection<string>' could be found (are you missing a using directive or an assembly reference?)…”
THX
You are missing a
using System.Linqon the top?