0

When I run locally my static files under wwwroot are served up without problem as follows:

https://localhost:5001/content/blah...

enter image description here

However, under aks (Azure Kubernetes Service, I get 404 not found when doing this:

https://{myDns}/{myAksService}/content/blah...

app.UseStaticFiles(); // Serve files from wwwroot

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider =
        new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/.well-known")),
    RequestPath = new PathString("/.well-known"),
    ServeUnknownFileTypes = true // serve extensionless file
});

My understanding is that the first UseStaticFiles should result in serving up the files under wwwroot

The .well-known files which are called out in separate UseStaticFiles are served up without issue under aks

https://{myDns}/{myAksService}/.well-known/apple-developer-merchantid-domain-association.txt

David Maze
  • 130,717
  • 29
  • 175
  • 215

2 Answers2

0

The root cause is the folder .well-known not been included under the wwwroot. You can verify it by checking the publish files.

How to fix it?

We can include the foler and files while deploying the project.

ASP.NET Core: Exclude or include files on publish

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
0

Maybe this will save somebody a lot of trouble in the future, it was a case-sensitivity issue.

So in turns out that UseStaticFiles works just fine.

app.UseStaticFiles(); // Serve files from wwwroot

This was my problem:

  • https://{myDns}/{myAksService}/content/blah (doesn't work)

This works:

  • https://{myDns}/{myAksService}/Content/blah (works just fine)

My source code:

enter image description here

For further context my asp.net core service is running under AKS linux, and linux static files are case sensitive, see here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#:~:text=configuration%20files%2C%20etc.-,The%20URLs,-for%20content%20exposed