dotnet / dotnet/aspnetcore

Blazor ServerApp does not follow wwwroot/* Symlinks

Open
#48,986 2 comments 0 reactions 0 assignees View on GitHub
area-networking
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

When the server app is run, any file inside wwwroot that is linked through a symlink is not followed and instead the symbolic link itself is sent. I think this is a bug because if the symbolic link is invalid then it is a 404 response, but when valid it is a 200 response with the symbolic link itself as the contents.

This became a problem while trying to use Nix to build a docker container. Nix makes plenty of use of symbolic links as it doesn't use a traditional FHS hierarchy. It copied the files to the docker container's root as symbolic links.

### Expected Behavior

Stylesheets and other files inside of the ./wwwroot folder are resolved and loaded instead of sending the symbolic link file itself.

### Steps To Reproduce

[dockerTools-Blazor-Issue](https://github.com/Zylanx/dockerTools-Blazor-Issue)

You can also under linux use:
```
dotnet new blazorserver -o Example
cd Example
dotnet publish -o publish
cd publish
mkdir wwwroot/link
mv wwwroot/Example.styles.css wwwroot/link
ln -s ./link/Example.styles.css wwwroot/
dotnet Example.dll
```
And you can see the symbolic link is sent.
If you make the symbolic link invalid, you will notice that it is instead a 404.

### Exceptions (if any)

_No response_

### .NET Version

7.0.304

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the Linux commands in the report, using the generated Example project and its wwwroot symlink, then compare valid and invalid links. Trace how the running Example.dll serves files from wwwroot; done means valid linked stylesheets and other files are resolved and served, while invalid links remain 404 responses.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, linux
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.