Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
sameerkattel opened this issue Jan 3, 2025 · 0 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Comments

@sameerkattel
Copy link

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

No branches or pull requests

1 participant