Hi there, I have done some searching but have struggled to find a definitive answer to the best way of developing an MVC web app with a dynamic UI in the most performant manner in ASP.NET Core.
We have an existing web app written using MVC4 that uses partial views to render a dynamic UI in Razor CSHTML but I have found that the performance leaves a lot to be desired. For example, we load an object that contains some data and a number of dynamically defined columns and then loop through each data row in a razor view and then loop through each column - for every cell we then dynamically call a partial view that renders an appropriate editor/renderer for that cell depending on the data type - date, string, number etc. Even on a read only grid when I hardcode this partial view to a simple control that literally just renders a <span>@value<span> type thing the render time for 6-7 columns over 100 rows can be as much as 500ms consistently, even when deployed to a decent server. This seems like a large amount of time and seems to be down to referencing the partial view (via @Html.Partial("~/Views/Controls/StaticTextControl.cshtml", value) for each cell. If I remove the @Html.Partial and replace that with an inline<span>@value</span> then the render time for the grid is hugely faster. The large amount of controls we use inside the cells, along with the fact that they are also shared with other display components means inlining all that logic would be impractical.
I was thinking of attempting to migrate the solution to ASP.NET Core 2.0 and was wondering, am I going to run into the same issues there and if so, is there a recommended way of dealing with a more dynamic UI scenario? Would migrating the partial views for each of the cell renderers to ViewComponent help at all with render performance? This is probably the wrong forum but are there any patterns for existing MVC4/5 for dynamic UI that might also help?
Any advice would be greatly appreciated!
Thanks very much,
James.