Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Bug? Required properties causes problems with forms submits

$
0
0

A viewmodel can have many properties to be used by the view. Ideally you want to include only those that will be used.

But sometimes you have many forms on one page. Let's say you have one form that sends only two properties, like a date and a string.

but if you have in the recieving method for that form submit a check for ModelState.IsValid, you will get a false if the viewmodel has another property that has a requred attribute. This requred property is not supposed to be relevant because you want only to send two other properties that has nothing to do with that one.

Is this a bug or, if it's not, why? What are possible solutions to this, because I want validation on my properties(the only solution that make it work is to remove the requred attribute)?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>