I have a REST API controller in new .NET CORE app. If I make the following call: https://localhost/api/search?query=someText, I am able to execute the code below, so it looks like the routing is correct, however, query.query is always null. I would expect the value to be "someText".
What is wrong here?
[HttpGet]
public IActionResult Get([FromQuery]SearchQuery query)
{
}
public class SearchQuery
{
[FromQuery(Name = "query")]
public string query { get; set; }
}
SearchQuery querytoSearchQuery modelto avoid ambiguity with the property name inside your model.