I have an MVC app. At a particular point I manually added an error to the ModelState.
ModelState.AddModelError("duplicateInvoiceNumberOrganisation", "The combination of organisation and invoice number must be unique");
What I’m wanting to know is how later from the controller do I get the value of error.
I know I can get to the ModelStateValues by:
controller.ModelState.Values
and it’s in there because it says:
Count = 1
[0]: {System.Web.Mvc.ModelState}
But how do I actually get the "The combination of organisation and invoice number must be unique" out of it?
or to the get the first error of the first modelstate item that has errors associated with it: