RazorEngine
RazorEngine copied to clipboard
Cannot call Engine.Razor.RunCompile twice in application
Hi all,
I have a problem when working with Razor Engine, I call the method Engine.Razor.RunCompile (needed parameters) in my MVC Web application. First time, It worked but the second times with the exception below (re-click on button to call the method ) :
An exception of type 'System.ObjectDisposedException' occurred in RazorEngine.dll but was not handled in user code Additional information: Safe handle has been closed
Anyone help me on this ?
I guess that you need to check if is in cache before.
if (razorEngine.IsTemplateCached(TemplateName, typeof(T)))
{
resultHtml = razorEngine.Run(TemplateName, typeof(T), model);
}
else
{
resultHtml = razorEngine.RunCompile(BaseTemplateContent, TemplateName, typeof(T), model);
}
@htatuan A sample application reproducing the problem is needed to fix this (or even better a unit test). Closing until then...