Route template parameters order cannot be changed even with ODataAttributeRoutingAttribute
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
ASP.NET Core OData 8.0.11
Describe the bug
Refering to this post from @xuzhg
https://stackoverflow.com/questions/72182707/odata-v7-8-should-composite-keys-be-in-alpha-order-or-haskey-when-key-value
Or you can use the attribute routing. In attribute routing, you can set any order in the route template.
I tried with ODataRoutingSample and it didn't work (or I didn't understand something)
Reproduce steps
- Open the AspNetCoreOData solution
- Edit
ODataRoutingSample.Controllers.PeopleControllerto inherit fromODataController(which has aODataAttributeRoutingattribute) - Launch the ODataRoutingSample project
This request works :
http://localhost:64771/People(FirstName='Magazine',LastName='Jingchan')
But this request does not work (404) :
http://localhost:64771/People(LastName='Jingchan',FirstName='Magazine')
Additional context
I think it is important to allow the key parameters to be specified in any order.
I know you can enforce it with the Order property in the model configuration, but since query parameters in MVC can be set in any order, same is expected for the key parameters from the route template.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by opening the AspNetCoreOData solution and the ODataRoutingSample.Controllers.PeopleController described in the reproduction steps. Run the sample and compare the two People requests with reversed key parameters, then trace the ODataAttributeRouting behavior. Done means both URL parameter orders route successfully instead of the reversed order returning 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100