2

I was wondering if it is possible to automatically add errors to the ModelState, in order to check my else condition?

if (ModelState.IsValid)
{
   //Do something
}
else
{
   //Manage errors
}

1 Answer 1

5
ModelState.AddModelError("Name", "Name is mandatory");

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.