Open graott opened 4 years ago
Thanks for contacting us.
We're moving this issue to the Next sprint planning
milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Thanks for contacting us.
We're moving this issue to the .NET 8 Planning
milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
There seems to be a problem with rendering null
model values, but only when returning a PageResult
from an action. Rather than rendering an empty value, it renders the previously rendered value. Maybe this is only a symptom of the real root cause but this seems like a legitimate bug to me.
This is a quite an issue for dynamically added collection items. The reason data corruption occurs is during model binding non-sequential indices used as they are, including in modelState, but when invalid view or page is re-rendered, collection indices become sequential. I think, default model binding should fix non-sequential indices to sequential before validation.
The Issue
If a razor page posts a collection of elements that use explicit indexing, where the explicit index is non sequential and non numerically ordered and the data they submit won't pass model validation on the server side. Then when the page is returned with the validation error the input fields will have incorrect data in them.
For example this data when posted (including the corresponding Parent.Child.Index fields) with a validation error will be rendered fine when the page returns.
As will this:
This however won't be:
To Reproduce
I have reproduced this by creating a simple model that has a parent class that contains a number of children. I render the parent out on a razor page and have a button that appends new children items dynamically in a random order using javascript. If the user then posts the data back with a non valid field (Note client side validation is turned off for this example.) then the form will show corrupted data.
If you debug the model that is posted back you can see that it is uncorrupted. It only gets corrupted when the page has been rendered out.
Code steps to reproduce the issue:
Create a brand new razor pages web app .netcore 3.1 application
Create a basic Model.
Create a new razorpage code-behind file to process the data:
Further technical details