Skip to content

URI parameter has null value in ODATA controllers #337

Closed
@GennadyGS

Description

@GennadyGS

When ODATA controllers have non-conventional names, action parameters, populated from URI, have null values.

Example (can be verified in ODataBasicSample):

    [ODataRoutePrefix( "People" )]
    public class PeopleNamesController : ODataController
    {
        [ODataRoute( "({id})/LastName" )]
        public IActionResult GetLastName( [FromODataUri] string id, ODataQueryOptions<Person> options ) =>
            Ok( new { LastName = $"{id ?? "null"}-lastName" } );
   }

Request:
http://localhost:1238/api/People(1)/LastName?api-version=1.0

Actual response:

{
    "lastName": "null-lastName"
}

Expected response:

{
    "lastName": "1-lastName"
}

Changing name of controller to PeopleController fixes the problem, however sometimes it is required to split big controller into several smaller ones. One of the reasons to do that is workaround to issue #336.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions