How to get an error from model state

I use

modelstate.Adderror("test","test message") 

And how can I get this modelstate value in the controller itself.

How do I need to get the error message "test" in the controller.

+4
source share
2 answers

He asks in the controller, I canโ€™t check this, but I think itโ€™s just something like:

 ModelState["test"].Value ModelState["test"].Error ModelState["test"] 

One of the above.

+5
source

Try <%=Html.ValidationMessage("Test") %> .

+1
source

All Articles