index.html default file not found when using UseDefaultFiles and MapStaticAssets (ASP.NET 9)
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I'm currently learning ASP.NET Core.
From an empty .NET 9 Web application, I added a wwwroot folder with an index.html file.
In Program.cs, I used UseDefaultFiles and MapStaticAssets as follows :
```C#
app.UseHttpsRedirection();
app.UseDefaultFiles();
//comment the line 13 and uncomment line 14 to make it work
app.MapStaticAssets();
//app.UseStaticFiles();
```
- When I go to the [web site without sepifying the index.html page](https://localhost:58716/), I get a 404 error.
- If I [specify index.html](https://localhost:58716/index.html), no 404 error, but I get the console error net::ERR_CONTENT_DECODING_FAILED 200 (OK) as reported in [issue #58940 ](https://github.com/dotnet/aspnetcore/issues/58940).
- If I replace the call to MapStaticAssets with a call to UseStaticFiles (the commented line), everything works fine.
### Expected Behavior
The expected behavior is simply to see my index.html page rendered by the brower.
### Steps To Reproduce
Github repo with the simpliest sln to reproduce the issue: [MapStaticAssets-issue](https://github.com/tehmang/MapStaticAssets-issue)
### Exceptions (if any)
_No response_
### .NET Version
9.0.101
### Anything else?
VS 2022 17.12.3
dotnet --info:
SDK .NET :
Version: 9.0.101
Commit: eedb237549
Workload version: 9.0.100-manifests.4a280210
MSBuild version: 17.12.12+1cce77968
Environnement d'exécution :
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.101\
Charges de travail .NET installées :
[android]
Source de l’installation: VS 17.12.35527.113
Version de manifeste: 35.0.7/9.0.100
Chemin d'accès au Manifeste: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json
Type d'installation: Msi
[aspire]
Source de l’installation: VS 17.12.35527.113
Version de manifeste: 8.2.2/8.0.100
Chemin d'accès au Manifeste: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Type d'installation: Msi
[maui-windows]
Source de l’installation: VS 17.12.35527.113
Version de manifeste: 9.0.0/9.0.100
Chemin d'accès au Manifeste: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.0\WorkloadManifest.json
Type d'installation: Msi
[maccatalyst]
Source de l’installation: VS 17.12.35527.113
Version de manifeste: 18.1.9163/9.0.100
Chemin d'accès au Manifeste: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.1.9163\WorkloadManifest.json
Type d'installation: Msi
[ios]
Source de l’installation: VS 17.12.35527.113
Version de manifeste: 18.1.9163/9.0.100
Chemin d'accès au Manifeste: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.1.9163\WorkloadManifest.json
Type d'installation: Msi
Configuré pour utiliser loose manifests lors de l’installation de nouveaux manifestes.
Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
.NET SDKs installed:
9.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Contributor guide
Assessment
This issue has not been assessed yet.