Short and simple. I have a route like this:
config.Routes.MapHttpRoute(
name: "QuickSearch",
routeTemplate: "QuickSearch/{searchQuery}",
defaults: new { controller = "QuickSearch", action = "Search" },
constraints: new { httpMethod = new HttpMethodConstraint(new string[] { "GET" }), }
);
And an action that looks like this:
public class QuickSearchController : ApiController
{
[HttpGet]
public QuickSearchResponse Search(string searchQuery)
{
}
}
If I call http://localhost:4096/QuickSearch/SearchMe
, then "SearchMe" gets bound to the searchQuery parameter, and the Search method is invoked successfully.
If, however, I call http://localhost:4096/QuickSearch/?searchQuery=SearchMe
then I receive a 404 message saying that the "Requested URL: /QuickSearch" cannot be found.
I thought the above URLs would be equivilent? Why doesn't it work when I use a query string?