Skip to content

FromQuery binding does not work when query param has same name as controller parameter name #59698

@sameerkattel

Description

@sameerkattel

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have this class


public class GetAuditTrail 
{


    public string Section { get; set; }

    public string Command { get; set; }


    public int? Page { get; set; }

    public int? PageSize { get; set; }
}

and in controller I have

        public async Task<IActionResult> GetAuditTrail([FromQuery] GetAuditTrail command,
    CancellationToken cancellationToken){

}

and now when hitting controller with command in query params in the request does not bind the query params with model

https://10.0.10.4/api/auditTrail?pageSize=100 this works

https://10.0.10.4/api/auditTrail?pageSize=100&command=test //model binding does not work

Expected Behavior

Expect model binding to work

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

8.0.204

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions