Rendering of partial view clears ModelState errors
Found in
EPiServer.CMS.Core 12.17.1
Fixed in
EPiServer.CMS.Core 12.18.0
Created
Sep 07, 2023
Updated
Sep 18, 2023
Area
CMS Core
State
Closed, Fixed and tested
Description
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.