I have the following action method (as suggested by Vague).
public IActionResult Document(string name)
{
try
{
var filepath = $"wwwroot/{name}";
byte[] fileBytes = System.IO.File.ReadAllBytes(filepath);
return File(fileBytes, "application/x-msdownload", name);
}
catch (Exception exception) { return Ok(exception.Message) }
}
When I execute in locally, I get the files as expected. However, when I upload to Azure, I get the error that the path is wrong.
Could not find a part of the path 'D:\Windows\system32\wwwroot\doc02.doc'.
Assuming that it's about the path being incorrect, I've tried all combinations of prefixing with "~", ".", "./" etc. that I could think of. After a few hours, I realize that it's an ostrich (you can try and try but it ain't gonna fly).
What can I be missing?
I put files to "always upload", of course. And I verified by entering the URL to said files (they are in the root directory, right next to logo.gif).