-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
System.InvalidCastException: Unable to cast object of type 'TemplateNamespace.Template' to type 'com.etsoo.Web.RazorHtmlSafeTemplate'. com.etsoo.Web.RazorHtmlSafeTemplate is extended from RazorEngineTemplateBase.
`
// Get or add the compiled version
if (!templateCache.TryGetValue(key, out var compiledTemplate))
{
// Engine
var razorEngine = new RazorEngine();
// Compile
compiledTemplate = await razorEngine.CompileAsync<RazorHtmlSafeTemplate>(template, builder =>
{
builder.AddAssemblyReference(typeof(M));
if (types != null)
{
foreach (var assembly in types)
{
builder.AddAssemblyReference(assembly);
}
}
}, cancellationToken);
templateCache.TryAdd(key, compiledTemplate);
}
// Run and return the result
return await compiledTemplate.RunAsync(template => template.Model = model);
`
Debug shows it happens inside the "RunAsync".
Metadata
Metadata
Assignees
Labels
No labels