-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
We have an existing .NET 8 application which has the following projects types:
- Microsoft.NET.Sdk.BlazorWebAssembly: Form 1 UI
- Microsoft.NET.Sdk.Web: API which also hosts the Form 1 UI project
- Microsoft.NET.Sdk.Razor: Razor Component Library (RCL) used by the Form 1 UI
- Microsoft.NET.Sdk: Services used by API project
- Microsoft.NET.Sdk: Class Library shared by Services, API, and the Form 1 UI projects
It has the following URLs:
- /forms/api/myService - provides APIs used by the UI
- /forms/form1/ - serves the Form 1 UI
We will soon be adding the following URLs:
- /forms/form2/ - serves Form 2 UI
- /forms/form3/ - serves Form 3 UI
These new projects will use the existing RCL and Class Library projects.
We have been unable to follow the guidance provide in the
Migration Docs
to update UseStaticFiles
to MapStaticAssets
.
In this solution, we have provided a minimal reproduction of the problems we are having.
This solution contains the following projects which were created using the current .NET 9 templates:
- MyApp: equivalent to our API project
- MyApp.Client: equivalent to our Form 1 UI project
We have updated these projects as follows:
- MyApp -> Program.cs: added
app.UsePathBase("/forms")
- MyApp -> Program.cs: added
options.PathPrefix = "/form1"
toAddInteractiveWebAssemblyRenderMode
per Prefix Docs - MyApp -> App.razor: added
<base href="/form1/" />
- MyApp.Client.csproj: tried adding
<StaticWebAssetBasePath>form1</StaticWebAssetBasePath>
but it didn't help
Expected Behavior
URLs are not returning expected values:
URL | Expected | Actual |
---|---|---|
/forms/form1 | Form 1 UI | HTTP 404 |
/forms | HTTP 404 | static HTML of App.razor |
/ | HTTP 404 | static HTML of App.razor |
Steps To Reproduce
Repo available at https://github.com/dougclutter/MapStaticAssetsIssues
Exceptions (if any)
No response
.NET Version
9.0.303
Anything else?
ASP.NET Core v9.0.7
VS Enterprise v17.14.9
dotnet --info
.NET SDK:
Version: 9.0.303
Commit: 5d97611193
Workload version: 9.0.300-manifests.183aaee6
MSBuild version: 17.14.13+65391c53b
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.303\
.NET workloads installed:
[android]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 35.0.78/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.78\WorkloadManifest.json
Install Type: Msi
[aspire]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 18.5.9207/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.5.9207\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 18.5.9207/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.5.9207\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 9.0.51/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.51\WorkloadManifest.json
Install Type: Msi
[wasm-tools]
Installation Source: SDK 9.0.300, VS 17.14.36310.24
Manifest Version: 9.0.7/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.7\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.7
Architecture: x64
Commit: 3c298d9f00
.NET SDKs installed:
6.0.428 [C:\Program Files\dotnet\sdk]
7.0.410 [C:\Program Files\dotnet\sdk]
8.0.412 [C:\Program Files\dotnet\sdk]
9.0.302 [C:\Program Files\dotnet\sdk]
9.0.303 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.7 [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