WebApplicationBuilder and IStartupFilter break routing if split between them
- 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
As described in my comment in: https://github.com/dotnet/aspnetcore/issues/44599
When calling UseRouting() in IStartupFilter, it will not see endpoints mapped by WebApplication.MapControllers().
```csharp
// Presume this is nuget
class FooStartupFilter: IStartupFilter {
public Action Configure(Action next)
=> builder => {
builder.UseRouting();
builder.Use(next => ctx => {
// do something with Endpoint.
});
next(builder);
}
}
```
```
var builder = ....; // get WebApplicationBuilder
builder.Services.AddTransient();
var webApplication = builder.Build();
webApplication .MapControllers();
```
Second middleware in IStartupFilter will not see any endpoints unless UseEndpoints(e => e.MapControllers()) is added.
### Expected Behavior
UseRouting in IStartupFilter should be able to access mapped routes that were mapped on WebAppliaction and vice versa.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
_No response_
### Anything else?
Most likely caused by WebApplicationBuilder.cs:395.
Contributor guide
Assessment
This issue has not been assessed yet.