Rendering of partial view clears ModelState errors
Sep 07, 2023
Sep 18, 2023
Closed, Fixed and tested
Fixed an issue that cleared errors on ViewContext.ModelState when you rendered a partial content (such as through a content area). For example:
- Add following line to DefaultPageController.Index method.
ModelState.AddModelError("AnError", "some error");
- Put breakpoints in a view that renders a contentarea before and after the contentarea (such as StandardPage/index.cshmtl)
- Access a page that contained an area item that is rendered with a view such as https://localhost:5000/en/about-us/
- In the breakpoint before the rendering of the contentarea, look at ViewContext.ModelState. The error was present in the breakpoint before rendering the content area but Errors was cleared after the rendering of the contentarea.