Debugging - adoconnection/RazorEngineCore GitHub Wiki
Templates can be debugged in VisualStudio.
- Compile template with
IncludeDebuggingInfo()
option. It will produce and keep PDB and Template source code.
IRazorEngineCompiledTemplate template2 = razorEngine.Compile(templateText, builder =>
{
builder.IncludeDebuggingInfo();
});
- 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"
});
-
Use
@{ Breakpoint(); }
code to stop at particular line -
when you run the code VS will ask you for cshtml file location
this will be either your bin
folder or specific path specified in EnableDebugging("MyTempPath")