dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.46k stars 10.03k forks source link

Github Pages (Blazor WASM): Page returns 404 when using direct links instead of navigating via Index.razor/html #38797

Closed TDuffinNTU closed 2 years ago

TDuffinNTU commented 2 years ago

Describe the bug

I'm deploying my basic Blazor website via Github Pages. You can see the actions I run to deploy it here, but basically the static files in wwwroot are built and copied into the gh-pages branch to be served.

When you use a direct link to a page outside of the home page, github pages returns a 404 error. Example (only 1 page outside of index.razor atm)

https://tduffinntu.github.io/gh-blazor/projects

To Reproduce

Create and deploy a Blazor WASM app to github pages. The boilerplate project works fine for this.

Copy the link to a page outside of your main landing page (ie counter/fetchdata pages) and paste into navbar, and attempt to load the page.

You should get a 404.

Further technical details

dotnet --info Output ``` .NET SDK (reflecting any global.json): Version: 5.0.401 Commit: 4bef5f3dbf Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.401\ Host (useful for support): Version: 5.0.10 Commit: e1825b4928 .NET SDKs installed: 5.0.401 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] ```
TDuffinNTU commented 2 years ago

I appreciate this could be a setup issue on my part; it's my first time doing Blazor stuff. Any help to point me in the right direction would be appreciated.