> For the complete documentation index, see [llms.txt](https://roshan-kr-grg.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roshan-kr-grg.gitbook.io/blog/programming/.net/get-the-keys-with-model-state-errors-in-mvc.md).

# Get the keys with model state errors in MVC

## Get the keys with model state errors in MVC

```
var keys = from m in ModelState                                     
                    where m.Value.Errors.Any()
                    select m.Key;
```

```
var errors = ModelState.Values.SelectMany(v => v.Errors);
```
