Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.Net MVC 2 RC2: Custom route returns 404 when all optional parameters are null
    primarykey
    data
    text
    <p>I get a 404 error when I navigate to the following URL using the route below:</p> <p><a href="http://localhost:53999/properties/" rel="nofollow noreferrer">http://localhost:53999/properties/</a></p> <p>However, all the following are correctly routed to the <em>List</em> action in my controller:</p> <p><a href="http://localhost:53999/properties/usa/new-york/manhattan/12" rel="nofollow noreferrer">http://localhost:53999/properties/usa/new-york/manhattan/12</a></p> <p><a href="http://localhost:53999/properties/usa/new-york/manhattan" rel="nofollow noreferrer">http://localhost:53999/properties/usa/new-york/manhattan</a></p> <p><a href="http://localhost:53999/properties/usa/new-york" rel="nofollow noreferrer">http://localhost:53999/properties/usa/new-york</a></p> <p><a href="http://localhost:53999/properties/usa" rel="nofollow noreferrer">http://localhost:53999/properties/usa</a></p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); //properties routes.MapRoute( "Properties", "Properties/{country}/{state}/{city}/{id}", new { controller = "Properties", action = "List", country = UrlParameter.Optional, state = UrlParameter.Optional, city = UrlParameter.Optional, id = UrlParameter.Optional } ); //default routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } </code></pre> <p>In PropertiesController.cs:</p> <pre><code>public ActionResult List(string country, string state, string city, string id) { return View(); } </code></pre> <p>Anyone know what I'm missing? Looks like it should just go to the default action, but it obviously doesn't...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload