-
Notifications
You must be signed in to change notification settings - Fork 585
Open
Description
I must compile a razor view in an azure function to send an email, but something goes wrong. I obtain the a NotSupportedException error: The given path's format is not supported.
Here my code:
private IRazorEngineService _engine;
public MyCtor(bool isTestEnvironment)
{
TemplateServiceConfiguration configuration = new TemplateServiceConfiguration();
configuration.Debug = isTestEnvironment;
this._engine = RazorEngineService.Create(configuration);
}
public string GetHtmlEmailBody(string templateFileName, object emailData, string layoutFileName)
{
//Get data type of email data
Type emailDataType = emailData.GetType();
string layoutFullFileName = Path.Combine(this._layoutPath, layoutFileName);
string layoutContentString = File.ReadAllText(layoutFullFileName);
var layout = new LoadedTemplateSource(layoutContentString, layoutFullFileName);
this._engine.AddTemplate("layoutName", layout);
string templateFullFileName = Path.Combine(this._templatePath, templateFileName);
string templateContentString = File.ReadAllText(templateFullFileName);
var template = new LoadedTemplateSource(templateContentString, templateFullFileName);
this._engine.AddTemplate("templateName", template);
this._engine.Compile("templateName"); //<-- Here I get the exception
string htmlEmailBody = this._engine.Run("templateName", emailDataType, emailData);
return htmlEmailBody;
}
Paths are similar to D:\\...\\Emails\\Templates.. I am testing locally and it does not work... I have googled and it seems that Azure Functions have some limitations in caching and in file system management, but it is not clear how can I solve the problem. I think I have same problem this person has written here
Any idea how can I solve it? There is something wrong in what I am doing?
I am using RazorEngine 3.10.0
Thank you
Metadata
Metadata
Assignees
Labels
No labels