RazorLight: Layout not rendered when using await IncludeAsync using .NET Core 3
Describe the bug Layout not being rendered when using await IncludeAsync using .NET Core 3.
To Reproduce The following code does not render the layout.
@inherits RazorLight.TemplatePage<MyModel>
@{
Layout = "_Layout.cshtml";
}
<p>
@{
await IncludeAsync("_LetterHeader.cshtml", Model);
}
</p>
Note that MyModel implements an interface that is accepted by _LetterHeader.cshtml, but I assume that this is not the issue as the letter header renders fine.
The following does render the layout.
@inherits RazorLight.TemplatePage<MyModel>
@{
Layout = "_Layout.cshtml";
}
<p>Hello</p>
Expected behavior The layout should be rendered when using await IncludeAsync.
Information (please complete the following information):
- OS: Windows 10
- Platform: .NET Core 3.0
- RazorLight version: current branch as at 28/11/2019
- Visual Studio version: Visual Studio Community 2019 16.3.4
Additional context None
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 30 (13 by maintainers)
Commits related to this issue
- Implemented workaround suggested by https://github.com/toddams/RazorLight/issues/287 — committed to ronnypmuliawan/RazorLight by ronnypmuliawan 4 years ago
I believe I have successfully created a Pull Request. Please let me know if that is how you wanted it done. thanks.
Hi all, the Layout is also not rendering on ASP.NET Core 2.2 project.
@jzabroski any timeline to fix this issue or workaround that I can implement?
Information (please complete the following information):
OS: Windows 10 Platform: ASP.NET Core 2.2 RazorLight version: 2.0.0-beta.4 Visual Studio version: Visual Studio Pro 2019 16.4.0
Ok, I have had a look at this just now, and as a simple experiment made the
TemplateRendererstateless, so it looks like this:Then on the
EngineHandler:Quickly tested this and it works. Do you want to give that a go @HamiltonManalo ?
@HamiltonManalo my first solution is really just a hack. What I go on to propose is for the
templateRenderer.RenderAsyncmethod to accept anITemplatePageas a parameter, since at the moment the parameter is ‘passed’ by setting theRazorPageproperty on thetemplateRendererwhich is very hacky and is really where the problem in the code lies. This is not a complete solution though just a high level suggestion, and it really needs somebody’s time to rethink the design of the renderer class. I will have a look at it at some point, but I am very busy atm so it’s not going to be for a while.@matthewwren Could you please send a PR with your findings? I would appreciate your input 😃
Any chance a fix for this could get into the next release?