I have a partial page containing the following javascript:
var url = '@Url.Action("Details", "Users", null)/' + userID;
This works fine on every page, except for pages with a URL structure:
/Site/Users/Details/{ID}
For example, when ID = 25, asp.net will output:
var url = '/Site/Users/Details/25/' + userID;
But it should be:
var url = '/Site/Users/Details/' + userID;
How can I prevent @Url.Action from accepting this extra route value?
Edit:
My route contains the default route configuration ...
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
source share