C# ignored MapRoute using Url.Action

21 Views Asked by At

I created a custom MapRoute to handle a specific case. I created it in Program.cs in this way:

app.UseMvc(routes => {
    routes.MapRoute("default", "{controller=Login}/{action=Index}/{id?}");
    routes.MapRoute("another", "{anotherId}/{controller}/{action}/{id?}");
});

It works fine when I try to navigate using address bar. The problem is when I try to create url using Url.Action:

Url.Action(menu.Action, menu.Controller, new { anotherId = menu.AnotherId })

The result is an URL with anotherId as query string instead of url parameter. I realy don't undestand where is the problem?

0

There are 0 best solutions below