Using MapGroup with Blazor endpoints produces template error
- 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
Similar to https://github.com/dotnet/aspnetcore/issues/57843, but when I use MapGroup to map blazor endpoints to a different base path, I get the error:
`InvalidOperationException: Unable to find the provided template '/blazor/'`
In the blazor template, I replace
```
app.MapStaticAssets();
app.MapRazorComponents()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(BlazorBasePath.Client._Imports).Assembly);
```
with
```
var groupBuilder = app.MapGroup("/blazor");
groupBuilder
.MapStaticAssets();
groupBuilder
.MapRazorComponents()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(BlazorBasePath.Client._Imports).Assembly);
```
I suppose the first question is, is that a valid thing to do? The issue I mentioned above does it using UsePathBase, but it seemed better to do what I want with the newer MapGroup feature.
### Expected Behavior
Blazor site loads in new base path
### Steps To Reproduce
Repo: https://github.com/ptsoccer/BlazorBasePath
1. Create new Blazor Web App with WebAssembly as the interactive render mode. Other render modes might also error out, but I need WebAssembly.
2. Replace
```
app.MapStaticAssets();
app.MapRazorComponents()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(BlazorBasePath.Client._Imports).Assembly);
```
with
```
var groupBuilder = app.MapGroup("/blazor");
groupBuilder
.MapStaticAssets();
groupBuilder
.MapRazorComponents()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(BlazorBasePath.Client._Imports).Assembly);
```
in the generated template
3. Run the website and browse to /blazor, you should get the error mentioned above.
### Exceptions (if any)
_No response_
### .NET Version
10.0.101
### Anything else?
Microsoft.NETCore.App 10.0.1
Microsoft.AspNetCore.App 10.0.1
Contributor guide
Assessment
This issue has not been assessed yet.