I'm using a default route, so that I don't need to specify the controller.
routes.MapRoute(
"Default",
"{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
With this, I can create URLs like myapp.com/Customers rather than myapp.com/Home/Customers
When I test locally, everything is fine. When I upload a live version, any links generated with Html.ActionLink are empty. I know I'm using Html.ActionLink correctly, because it works fine locally:
// Title Action Controller
<%: Html.ActionLink("Manage My Settings", "Settings", "Home") %>
I've removed all routes but the default, tried specifying ActionLink with and without the controller etc. I even tried reverting to having the controller in the route, e.g:
"{controller}/{action}/{id}"
Nothing works live. Everything works locally. Going slightly mad.
UPDATE:
OK, made a strange discovery. I actually had another optional UrlParameter after id, called page. I stupidly didn't include it in the example because I thought it made no difference. If I take it out, things seem to work.
So, actually, this works:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
and this works!
routes.MapRoute(
"Default",
"{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
but this does Not work
routes.MapRoute(
"Default",
"{action}/{id}/{page}",
new { controller = "Home", action = "Index",
id = UrlParameter.Optional, page = UrlParameter.Optional }
);
Why Not?