Static files not found when deploying Razor Pages app to Linux
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
My dotnet Razor pages app runs fine with Visual Studio. However, when deployed to AWS Elastic Beanstalk on Linux, none of the static files can be found even they are in the uploaded zip file.
As a workaround, I've changed Program.cs from
`app.UseStaticFiles();`
to
```
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "wwwroot")),
RequestPath = ""
});
}
else
{
app.UseStaticFiles();
}
```
and the static files are now found. Clearly, the default directory doesn't work on Linux and possibly other platforms.
### Expected Behavior
Static files should be found using the defaults on Linux.
### Steps To Reproduce
* Create a simple aspnet core Razor Pages app with a Razor Page that displays a static image file
* Publish to a Linux server
### Exceptions (if any)
None
### .NET Version
8.0.204
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.