CompileRenderAsync fails to render very long htmls
See original GitHub issueDescribe the bug I’m using Razorlight to render HTML from the server. I have a view with 2 partial views inside. One partial view renders static HTML, while the other iterates through a collection and renders html for every item in it.
When the collection has many items (in my tests, 10 or more), the string returned from CompileRenderAsync doesn’t include the second partial view that iterates through the collection.
It doesn’t throws any exception, it just renders everything but the partial view that depends on the collection.
To Reproduce Steps to reproduce the behavior:
I have implemented this code, following the example on GitHub:
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject("physical-path-to-Views-folder")
.UseMemoryCachingProvider()
.Build();
var html = await engine.CompileRenderAsync("Report.cshtml", resultReport);
Report.cshtml has 2 partial views:
@inherits RazorLight.TemplatePage<MyAssembly.Data.Model.ResultReport>
@model MyAssembly.Data.Model.ResultReport
@{
await IncludeAsync("Partial/_summary.cshtml", Model);
await IncludeAsync("Partial/_riskReport.cshtml", Model);
}
_summary.cshtml shows static information from some properties of the model, while _riskReport.cshtml iterates through a collection of risks:
<div>
@foreach (var risk in Model.Risks)
{
<div class="@risk.Level">
<div class="title-container"><h2 class="title">@risk.Title</h2><h3 class="level">@risk.Level</h3></div>
<div>@Raw(risk.Description)</div>
</div>
}
</div>
Expected behavior It should render html with a Summary Section (_summary.cshtml) and a list of Risks (_riskReport.cshtml). When the list of Risk has many items, it only renders the Summary Section.
Information (please complete the following information):
- OS: Windows 7
- Platform Net. Core 2.1
- RazorLight version 2.0.0-beta1
- Visual Studio version Visual Studio 2017
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top GitHub Comments
UPDATE:
The error mentioned above happens when I use the NuGet Package Razorlight. I have tried downloading the project and manually adding it to my Application and now it works like a charm. However I cannot go that way. I need it to be a NuGet package.
The difference I’ve noticed is that when using the NuGet package, the following code:
has the method UseFilesystemProject with system in lower case. However when I manually add the project downloaded from GitHub, the method is UseFileSystemProject with System starting with capital letter.
Maybe an update is missing in the NuGet package?
EDIT 1:
The NuGet Package that is failing is called Razorlight and is the version 2.0.0-beta1 The code that works is the one I downloaded from the branch master as of today (7/10/2019)
EDIT 2:
It seems that the NuGet Package named Razorlight.Unofficial is the one using the current master branch and by using the latest version of that package (2.0.0-beta3) I was able to make the render work correctly.
Is there a plan to make this version “official”?
This is fixed by https://github.com/toddams/RazorLight/commit/0dbc5e1d174411530c3ab81db94dfc3444dd4a4d