views:

86

answers:

1

Original title: Can't fixed misconfigured routes

I want to make a search based in a filter (with 4 possibles values) and a criteria entered by the user.

I have the following routes:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
    "SubLineasProductosDefault",                                       
    "SubLineasProductos.aspx/Create",                           
    new { controller = "SubLineasProductos", action = "Create" }  
);

routes.MapRoute(
    "SubLineasProductosSearch",                                       
    "SubLineasProductos/Buscar.aspx/{filtro}/{criterio}",
    new { controller = "SubLineasProductos", action = "Buscar"}  
);

routes.MapRoute(
    "SubLineasProductos",                                     
    "SubLineasProductos.aspx/{id}",                           
    new { controller = "SubLineasProductos", action = "Index", id = "" }  
);

routes.MapRoute(
    "Default",                                              
    "{controller}.aspx/{action}/{id}",                           
    new { controller = "Home", action = "Index", id = "" }  
);

routes.MapRoute("Root", "", new { controller = "Home", action = "Index", 
  id = "" });

and the following form:

<% using (Html.BeginForm("Buscar", "SubLineasProductos", 
    FormMethod.Get)) { %> 
    <%= Html.Hidden("filtro", "nombre") %>
    <%= Html.TextBox("criterio") %>
    <button type="submit" title="Buscar">
     <img src='<%= Url.Content("") %>' alt="" />
    </button>
<% } %>

The form isn't redirecting to the action Buscar, but to the action Index in the SubLineasProductos controller. I think I have wrong my routes, but I don't know how to fixed them. I have read this post, and as much I can see all is fine in my routes.

How can I fix this? Thanks in advance.

EDIT: With the tool provided by Phil I can see that if I test an URL like

http://localhost/MyApp/SubLineasProductos/Buscar.aspx/nombre/block

it matches the route I want. But when I run my application and try to use the form posted before the generated URL has the form:

http://localhost/MyApp/SubLineasProductos.aspx/Buscar?filtro=nombre&amp;criterio=block

How can I fix this new problem?

+3  A: 

Have you tried using the Route Debugger I posted here: http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

Haacked
thank you for your time, Phil
eKek0