question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to compile generated Razor template. The name 'Render' does not exist in the current context

See original GitHub issue

Description 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:

  1. 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;
 }

  1. 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jzabroskicommented, Dec 22, 2019

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/toddams/RazorLight/issues/262?email_source=notifications&email_token=AADNH7LTFUDIX5XQ57FKXATQZ6237A5CNFSM4IBDF7FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHPXWUQ#issuecomment-568294226, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADNH7KZ3Q2SVPGE6YONYKTQZ6237ANCNFSM4IBDF7FA .

0reactions
gmarokovcommented, Dec 22, 2019

To inject the engine instead of creating it 😃 Regards

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found