ViewData in PageModel.Partial is not passed correctly
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
When a PartialViewResult is returned via:
return '((PageModel) this).Partial(viewName: "whatEver");'
The ViewData is not passed correctly.
That is because the method calls:
'Partial(viewName, model: null);'
Which initializes a new ViewData object for the given model.
PageModel.cs line 1660:
var viewData = new ViewDataDictionary(MetadataProvider, ViewData.ModelState)
{
Model = model,
};
Instead of throwing away the PageModel.ViewData contents, i would've expected it to sustain the information in there.
Contributor guide
Research direction
Start in PageModel.cs around line 1660 and trace the PageModel.Partial(viewName) overload that returns a PartialViewResult. Compare its handling of ViewData with the expected preservation of the PageModel.ViewData contents, then verify that returning a partial without a model retains the existing ViewData.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100