Azure 应用服务文件.ReadAllText 返回"找不到文件"异常,但该文件存在于该位置



我们在"内容/模板"文件夹下有 .cshtml 文件格式的电子邮件模板。我们使用File.ReadAllText((读取该模板,然后应用我们的模型值,然后将该邮件发送给特定用户。它在本地托管的计算机中工作正常。当我在 Azure 应用服务文件中托管我的 asp.net mvc 应用时,找不到异常引发。

private string GetTemplateContent(string templatePath)
{
var templateContent = string.Empty;
var path = GetAbsoluteTemplatePath(templatePath);
try
{
templateContent = File.ReadAllText(Path.GetFullPath(path));
}
catch (Exception ex)
{
Log exception
}
return templateContent;
}

Azure 中的路径 "D:\home\site\wwwroot\Content\Templates\ScheduleTemplate.cshtml">

我确保文件存在于该位置。

你能帮我为什么会这样吗?

这是Azure 应用服务问题。从这个线程中,我们找到了解决方案。 在应用程序设置中添加节点

键:WEBSITE_DYNAMIC_CACHE(全部大写( 值:0

相关内容

最新更新