in one of my asp.net mvc 2 views I have the following statement
window.location.href = '<% = Url.Action("Index","Feature", new {id=""}) %>/' + $("#ProductId").val();
as you can see $ ("# ProductId"). val () can only be computed from a client action and therefore outside of url.Action
I have my routes as shown below:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" }); routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); routes.IgnoreRoute("{*allimages}", new {allimages = @".*\.jpg(/.*)?"}); routes.MapRoute( "Default", // Route name "{controller}.mvc/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.MapRoute( "DefaultIndex", // Route name "{controller}.mvc/{id}", // URL with parameters new { controller = "Home", action = "Index"} // Parameter defaults ); routes.MapRoute("Root", "", new { controller = "Home", action = "Index", id = "" }); }
The request with Url.Action does not work, because the route believes that the "action" is "id" 
How can I make sure the route setting in "DefaultIndex" is checked and the URL is
Key → Value
controller = Feature
action = index
id = 9a1347dc-60b0-4b3b-9570-9ed100b6bc6a
Edit 2
Image 2:

Change 1- Route Order
I almost decided that I solved it by changing the order of the route
routes.MapRoute( "DefaultIndex", // Route name "{controller}.mvc/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.MapRoute( "Default", // Route name "{controller}.mvc/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); routes.MapRoute("Root", "", new { controller = "Home", action = "Index", id = "" });
it really worked http: // localhost: 61000 / Feature.mvc / 9a1347dc-60b0-4b3b-9570-9ed100b6bc6a /
but failed for posting on the same page
http: // localhost: 61000 / Product.mvc / List
**** History ****
Used + $ ("# ProductId"). val (); = "/ domainname [virtual directory alias] /Fewature.mvc/Index" + $ ("# ProductId"). val ();
always worked, although I had to change all the scenarios when sending to the domainname server [virtual directory alias] / changes from development to production testing
trying to arrange it:
The following statement used to be:
window.location.href = '<% = Url.Action ("Index", "Feature"})%> /' + $ ("# ProductId"). val ();
The result will be several Id values
http: // localhost: 61000 / Feature.mvc / 9a1347dc-60b0-4b3b-9570-9ed100b6bc6a / 3c5941e4-cb25-4d6f-9117-9ed100b4ca91
it maps the existing route {id} in Url.Action ("Index", "Feature"}
bringing NoMatch
Submitted by
new {id = ""} to get around it.