I have the following routes installed:
app.UseMvc(routes => { routes.MapRoute( name: "admin", template: "{controller=Home}/{action=Index}/{id?}", defaults: new {Area = "Admin"}, constraints: new {HostConstraint = new MyConstraint()}); routes.MapRoute( name: "admin-rep", template: "Rep/{controller=Home}/{action=Index}/{id?}", defaults: new { Area = "" }, constraints: new { HostConstraint = new MyConstraint() }); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
MyConstraint in this case always returns true .
- If I try to access the "/" route, I will return to the "Admin", "Home of the controller", "Action index" areas. Things are good.
- If I try to access "/ rep", then I will get to the root area, controller home, action index. OK. The problem is that this view has a link linking to another action in my HomeController (from the root area). I expected the link to point to / rep / home / action 2, but the generated route is / home / action2. Does this sound like a wrong match when creating urls?
<a asp-action="Action">Action</a> @Html.ActionLink("Action", "Action")
source share