dotnet / dotnet/aspnetcore

Endpoint information available before calling UseRouting()

Open
#50,393 5 comments 1 reaction 0 assignees View on GitHub
area-hosting bug
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 are updating applications to net7 and discovered problems serving static files. We have a Razor convention that maps any unknown url to /index. Using debug logging, we figured out that it didn't match any static file, and used the Razor convention instead.

Logging output:
```
1 candidate(s) found for the request path '/bundles/shell-bundle.es.js'
Endpoint '/Index' with route pattern '{*url}' is valid for the request path '/bundles/shell-bundle.es.js'
Request matched endpoint '/Index'
Static files was skipped as the request already matched an endpoint.
```

I have created a small repro. This works as excepted on net6, but fails on net7 and net8.
If I remove UsePathBase(), things seem to be working again.

### Expected Behavior

It should be possible to use

- Razor Convention
- UsePathBase()
- UseStaticFiles()

at the same time

### Steps To Reproduce

https://github.com/kimbell/RazorStatics

### Exceptions (if any)

_No response_

### .NET Version

8.0.100-preview.7.23376.3

### 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.