C# Azure应用程序服务文件.ReadAllText返回未找到文件异常,但该位置存在文件

C# Azure应用程序服务文件.ReadAllText返回未找到文件异常,但该位置存在文件,c#,html,asp.net-mvc,azure,azure-web-app-service,C#,Html,Asp.net Mvc,Azure,Azure Web App Service,我们在Content/templates文件夹下有.cshtml文件格式的电子邮件模板。我们使用File.ReadAllText()读取该模板,然后应用模型值,然后将该邮件发送给特定用户。它在本地托管的机器上运行良好。当我在Azure应用程序服务文件中托管我的asp.net mvc应用程序时,未找到异常引发 private string GetTemplateContent(string templatePath) { var templateContent = stri

我们在Content/templates文件夹下有.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\schedulemplate.cshtml”中的路径

我确保文件存在于该位置


你能告诉我为什么会发生这种情况吗?

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

关键字:网站\动态\缓存(所有大写)
值:0这是Azure应用程序服务问题。从中我们找到了解决办法。 在应用程序设置中添加节点

关键字:网站\动态\缓存(所有大写)
值:0

您是否可以共享GetAbsoluteTemplatePath和Path.GetFullPath返回的信息?@JatinParmar templatePath=“~/Content/Templates/ScheduleTemplate.cshtml”GetAbsoluteTemplatePath返回D:\home\site\wwwroot\/Content/Templates/ScheduleTemplate.cshtm\u l Path.GetFullPath返回D:\home\site\wwwroot\Content\Templates\ScheduleTemplate.cshtmlStart通过确保它在本地正确工作,根据异常执行以下操作,它表示文件不存在。您还可以远程调试它,并使用kudu再次检查文件。确保文件存在@TomSun同一方法有3行代码,第一个读取文件下一行写入新文件,然后第三个读取新写入的文件结果:第三行文件未找到异常能否共享有关GetAbsoluteTemplatePath和Path.GetFullPath返回内容的信息?@JatinParmar templatePath=“~/Content/Templates/ScheduleTemplate.cshtml”GetAbsoluteTemplatePath返回D:\home\site\wwwroot\/Content/Templates/ScheduleTemplate.cshtm\u l Path.GetFullPath返回D:\home\site\wwwroot\Content\Templates\ScheduleTemplate.cshtmlStart通过确保它在本地正确工作,根据异常执行以下操作,它表示文件不存在。您还可以远程调试它并使用kudu再次检查文件。确保文件存在@TomSun相同方法有3行代码,第一行读取文件下一行写入新文件,然后第三行读取新写入的文件结果:第三行文件未找到异常