I have the following form:
<form role="search" method="get" id="search-form" name="search-form" action="/video/pesquisa">
<div class="cover-pursuit-btn">
<button type="submit" value="Search" class="pursuit-btn"><span class="glyphicon glyphicon-search"></span></button>
</div>
<div class="coversquare">
<input type="text" class="square fild-placeholder" placeholder="Find in title or description" id="SearchString" name="SearchString" value="">
</div>
</form>
My method in the controller is:
[Route("video/pesquisa/{SearchString}/{page?}")]
public async Task<ActionResult> PesquisaVideo(string SearchString, int? page)
{
...
}
When I send the submit it executes the following URL:
http://localhost:59278/video/pesquisa?SearchString=teste
I do not understand why it does not perform correctly, since I already applied the route in the annotation:
http://localhost:59278/video/pesquisa/teste
What am I doing wrong?
UPDATING
This is RouteConfig.cs:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Categoria", action = "Index", id = UrlParameter.Optional }
);
}