- Notifications
You must be signed in to change notification settings - Fork 101
Debugging
Alexander Selishchev edited this page Nov 17, 2023
·
4 revisions
Templates can be debugged in VisualStudio.
- Compile template with
IncludeDebuggingInfo()option. It will produce and keep PDB and Template source code.
IRazorEngineCompiledTemplatetemplate2=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 directorystringresult=template2.Run(new{Title="Welcome"});Use
@{ Breakpoint(); }code to stop at particular linewhen 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")