Routing inconsistency
@KenitoInc is already working on this.
Since Apr 12, 2022.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Hi Team,
I have a simple controller - using Odata8.0.8 in .Net6
public class StudentsController : BaseExternalController
{
[HttpGet("Students/{key}/GetStudentGrades")]
public async Task<IActionResult> GetStudentGrades(string key)
{
business logic...
return Ok(grades);
}
}
I defined the method in my EDM:
var student= builder.EntitySet<Student>("students").EntityType;
student.HasKey(student => student.Id);
builder.AddComplexType(typeof(Grades)).Namespace = builder.Namespace;
var assets = student.Action(nameof(StudentsController.GetStudentGrades)).ReturnsCollection<Grades>();
assets.Namespace = builder.Namespace;
when trying to call the api/students/someId/GetStudentGrades I can't reach the endpoint (api is the Odata route prefix when constructing the route template.)
Important notes:
- changing only the http method attribute from
[HttpGet("Students/{key}/GetStudentGrades")]
to
[HttpPost("Students/{key}/GetStudentGrades")]
will solve the issue (will reach the endpoint as expected.)
-
The AspNetCore routing Works, Calling the method directly without the Odata prefix reaches the controller (
api/students/someId/GetStudentGrades) -
The same EDM / controller structure worked in OData in .net Framework 4.7.2 with Microsoft.AspNet.OData.7.5.12
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.
Assessment
This issue has not been assessed yet.