Given a class
public class SearchRepresentation
{
public string Search { get; set; }
public string Code { get; set; }
}
and a Controller method in controller SomeController
public SomeReturnType Get([FromUri] SearchRepresentation search)
{
// Do something here with search.Search or search.Code
}
and call the controller method with the following
http://webserver:port/api/somecontroller?search=red
The SearchRepresentation.Search variable will NOT be populated and both Search and Code will be null. If you change the variable name of the method to be [FromUri] SearchRepresentation xyz where xyz is NEITHER Search NOR Code, then the operation works as expected.
Comments: If we can't fix it, lets at least come up with a clear explanation to why this happens?
public class SearchRepresentation
{
public string Search { get; set; }
public string Code { get; set; }
}
and a Controller method in controller SomeController
public SomeReturnType Get([FromUri] SearchRepresentation search)
{
// Do something here with search.Search or search.Code
}
and call the controller method with the following
http://webserver:port/api/somecontroller?search=red
The SearchRepresentation.Search variable will NOT be populated and both Search and Code will be null. If you change the variable name of the method to be [FromUri] SearchRepresentation xyz where xyz is NEITHER Search NOR Code, then the operation works as expected.
Comments: If we can't fix it, lets at least come up with a clear explanation to why this happens?