Tuesday, February 12, 2019

View all model state errors while debugging

If we are in break mode while debugging an MVC controller event,  and want to view all ModelState errors, the following command can show all error messages in immediate window:


ModelState.Where(x => x.Value.Errors.Count>0).SelectMany((x, i)=> x.Value.Errors.Select(y=> "Key: " + x.Key + ", Error: " + y.ErrorMessage)).ToList()

No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...