Error when trying to get Razor email template on deployed server
pippinmole opened this issue · comments
I initialize the Razor renderer here, setting the template root folder, which works fine on my local machine, but once I deploy it to Heroku (Linux) it throws this exception:
They are running the same code, but different results? Very confusing to me.
This is the code that is sending the email:
I do see that I am overlapping /Email Templates - In Startup.cs I have $"{Directory.GetCurrentDirectory()}/Email Templates")
and then inside the SendResetPasswordAsync method, UsingTemplateFromFile("Email Templates/ResetPassword.cshtml"
, but it is confusing to me how this works fine on my desktop, but not in a production environment?
I could be doing something entirely wrong, or a bug
Instead of
.AddRazorRenderer($"{Directory.GetCurrentDirectory()}/Email Templates")
try
.AddRazorRender(options => options.FileProvider = new PhysicalFileProvider(Path.Combine(contentRootPath, "Email Templates")))
That still does not fix it, as the UsingTemplateFromFile
method is not correctly calling the renderer with the filename. It is trying to read the contents of the file first, then call the parse method of the renderer.
https://github.com/lukencode/FluentEmail/blob/master/src/FluentEmail.Core/Email.cs#L343
@lukencode Think we can get these little things fixed and deployed with new version?
This issue still not resolved on December. It seems that the FileProvider in RenderOptions is not used at all.