Skip to content
Alexander Selishchev edited this page Nov 17, 2023 · 4 revisions

Templates can be debugged in VisualStudio.

  1. Compile template with IncludeDebuggingInfo() option. It will produce and keep PDB and Template source code.
IRazorEngineCompiledTemplate template2 = razorEngine.Compile(templateText, builder =>
{
    builder.IncludeDebuggingInfo();
});
  1. Call EnableDebugging() before running template, it will write template source code to your active directory thus enabling VS to step into template.
template2.EnableDebugging(); // optional path to output directory

string result = template2.Run(new
{
    Title = "Welcome"
});
  1. Use @{ Breakpoint(); } code to stop at particular line
Clone this wiki locally