2
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 do Submit it executes the following URL:
http://localhost:59278/video/pesquisa?SearchString=teste
I do not understand why it does not execute so correct, since I have 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 }
);
}
You have the route
Default
configured in theRoutesConfig.cs
?– Leonel Sanches da Silva
Yeah, I didn’t change anything on Routesconfig.Cs
– Ricardo