dotnet / dotnet/aspnetcore

Wrong controller route param names

Open
#55,584 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
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

Hello, I've came across this case with 2+ controllers defined. Consider the following declarations for 2 different controller routes.

```csharp
app.MapControllerRoute(
name: "ProfilePicturesPublic",
pattern: "{controller=ProfilePictures}/{action=Public}/{picture}");

app.MapControllerRoute(
name: "Question",
pattern: "{controller=Question}/{action=Delete}/{id}");
```

What happens in reality is that Question controller route values will be "picture" and not "id".

### Expected Behavior

Route value names should be as declared. `ProfilePictures` controller should get the name `picture` and `Question` controller should get the name `id`.

### Steps To Reproduce

As described. Declare 2 controllers with the routing as above.

### Exceptions (if any)

None

### .NET Version

8.0.204

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