asp.net mvc: TryUpdateModel return value or ModelState.IsValid?

asp.net-mvc, modelbinders

Solution

The last line of the `TryUpdateModel` source code is:

        return ModelState.IsValid;

...which pretty much answers your question. :)

Problem

Doing validation in my binder, I'm wondering if there's a need to check the return value. In Option 1 below, is there ever going to be a difference in case 1 and case 2? It doesn't seem possible that TryUpdateModel would return true, but ModelState.IsValid is false. Option 1: ``` if (TryUpdateModel(editItem, new string[] { "Field" })) { if (ModelState.IsValid) { } else { // Invalid model case 1 } } else { // Invalid model case 2 } ``` Option 2: ``` TryUpdateModel(editItem, new string[] { "Field" })) if (ModelState.IsValid) { } else { // only one invalid model case } ```

Original source