dotnet / dotnet/aspnetcore

Enable case-insensitive route parameter binding for enums

Open
#56,369 0 comments 13 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

### Is your feature request related to a problem? Please describe the problem.

I have the exact same issue reported in #45590 which has been closed as resolved and locked due to lack of feedback from the author, but the issue is still prevalent in ASP.NET 8+.

The answer provided in that issue was essentially to implement a custom `TryParse`, and the linked documentation shows well enough how to do that; however, the C# language doesn't give us a way to implement static methods on enums.

Is there a way to do this that doesn't require a huge refactor to take a type from `enum` to `class` just to solve this parsing issue?

### Describe the solution you'd like

My desired outcome is a straightfoward (and preferrably not labor-intensive) way to enable case-insensitive route parameter binding for enums, specifically.

### Additional context

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