ASP .Net Core 2.2 发布到 Azure

ASP .Net Core 2.2 publish to Azure

我刚开始使用 Azure,但最近我将我的 ASP.Net 核心 2 应用程序发布到 App Service,无法从 API 中访问电子邮件模板 (.html) ].

API 工作正常,它连接到客户端和数据库,但是当我尝试发送电子邮件时 - 我收到异常:

Could not find a part of the path 'D:\home\site\{ProjectName}\EmailTemplate\template.html'.

在代码中,我使用以下路径格式调用模板:

../{ProjectName}/EmailTemplate/template.html

如何在托管环境中访问这些模板?

非常感谢, 亚历克斯

根据评论。

Right-click 在 vs 中的 html 模板上单击 Properties,然后更改 Copy to Output Directory > Copy Always.

此外,正如@jpgrassi 指出的那样,您还可以在 csproj 文件中添加模式以包含整个目录甚至所有以 .html 结尾的文件。您的项目只需 right-click 和 select Edit <Project Name>。然后只需添加:

<ItemGroup>
    <Content Include="EmailTemplate\*.html" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>