Data annotation validation will not fire when you use model binder as you are creating the objects manually using new keyword. Only and only if the objects come autommapped , i mean get automatically filled in the MVC action method input parameter then only ModelState validation will execute.
For firing validation model binder code you need to manually invoke the validation. I would suggest you to watch this C# data annotation which explains how to use data annotation with simple C# video https://www.youtube.com/watch?v=Gft64NdIx3k
So in the action method you need to invoke the "tryValidate" method and perform validations.
+91-9967590707 / +91-7700975156
Copyright © 2006 - 2022 Questpond. All Rights Reserved. Powered By imark
Are you sure You want to delete answer.
Wrong!, please try again.