dotnet / dotnet/aspnetcore

Combine MapWhen with UseAuthorization and many Endpoints is slow

Open
#54,664 0 comments 0 reactions 0 assignees View on GitHub
area-auth investigate Perf
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

We have several hundreds of endpoints and discovered that our startup time of our application is terrible slow.
After Investigation into this situation we enclosed the problem that the call to "UseAuthorization" makes the WebApplication configuration process slow.

See here the sample code to reproduce the issue:
https://gist.github.com/softwaretirol/a3169c404226fbe5193c70a721ec8cc5

With UseAuthorization() the console gives us a duration of "00:00:02.94".
Without UseAuthorization() the console gives us a duration of "00:00:00.023"

### Expected Behavior

Same performance with UseAuthorization as without UseAuthorization

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

8.0.100

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.