Failed to compile generated Razor template. The name 'Render' does not exist in the current context
See original GitHub issueDescription
Hi. I try to use view with layout but I get the following error:
Failed to compile generated Razor template: - (73:17) The name 'Render' does not exist in the current context
To Reproduce Steps to reproduce the behavior:
- My RazorLight setup:
private static string TEMPLATES_PATH = $@"{Directory.GetCurrentDirectory()}/Templates/Email";
public static async Task<string> RunCompile(string templateName, object model)
{
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject(TEMPLATES_PATH)
.UseMemoryCachingProvider()
.Build();
string result = await engine.CompileRenderAsync(templateName, model);
return result;
}
- The rest is like the Wiki page for Layout pages: I did step 1 the model creation and step 2 layout/children page. Haven’t performed the last step as it seems deprecated.
Information:
- OS: Fedora 30
- Platform .NET Core 2.1
- RazorLight version 2.0.0-beta1
The Wiki page probably needs update too, as when tried the code there, It was marked as obsolete.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Failed to compile generated Razor template ...
I had the exact same issue, but only within my published application. While debugging the worker service i didn't get the error message....
Read more >Razor file compilation in ASP.NET Core
Learn how compilation of Razor files occurs in an ASP.NET Core app. ... in Program.cs when the current environment is set to Development:....
Read more >Render Emails Using Razor Templating
Learn how to use different open-source Razor engines to render Razor templates to strings for sending emails.
Read more >How to: Render ASP.NET MVC Razor Views to Strings
In the code snippet above, I have a ControllerContext readily available, because the request is running inside of the context of an MVC ......
Read more >Generating HTML emails with RazorEngine - Part 04
RazorEngine.Templating.TemplateCompilationException : Unable to compile template. The name 'Html' does not exist in the current context.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool. Happy if i helped. One thing is that I an deprecated RazorLight.Mvc in 2.0.0 and moved AddRazorLight into the main package.
On Sun, Dec 22, 2019, 2:04 PM Georgi Marokov notifications@github.com wrote:
To inject the engine instead of creating it 😃 Regards