1

we can validate mandatory fields by using Required attribute but what about model what if we pass empty post body ? i have check the controller i am getting null object and ModelState.IsValid is true on action executing even though there are required fields in model. is there any way to validate null/empty body ?

1

1 Answer 1

1

You can as well check explicitly

if (inputModel == null) {
return BadRequest();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.