I am trying to understand asp.net server implementation and routing in particular. I have tried to search this forum for answers(for instance this link; WebApi 2.0 Routes not matching with query parameters?, but I havent gotten anything to work. I would like to have a form on the client side:
<"form id="search-form" name="search-form" method="get" action="page.html"
onsubmit="return validate();">
<"input id="inputText" name="question" type="text"
placeholder="Search..." class="inputsearch">
<"/form>
This will allow me to send a query (for instance "test") to the server, which would look like "page.html?question=test". My controller is called products (but it seems to me that I do not need to specify it in an action tag on the form, so I was thinking that I need some routing like:
[HttpGet]
[Route("~/api/products?{queryWord}")]
public IHttpActionResult test(string queryWord)
{
Debug.Write(queryWord);
return Ok("<html>hey</html>");
}
That seemed to be valid from the answers in that link, but I get an error message:
The route template cannot start with a '/' or '~' character and it cannot contain a '?' character. Parameter name: routeTemplate