简体   繁体   中英

ASP.NET MVC Routing & Html.ActionLink

In my routes file I have this setup:

        routes.MapRoute(
            name: "Stages", // Route name
            url: "Stages/{action}", // URL with parameters
            defaults: new { controller = "Tasks", action = "Index", taskTypeIds = new[] { TaskTypes.Stage } }
);

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

The problem now is that I want to define two main menu items:

                <li>@Html.RouteLink("Stages", "Stages")</li>
                <li>@Html.ActionLink("Tasks", "Index", "Tasks")</li>

But what this outputs for both is the same URL:

/Stages

Why is it doing this, and can I get around it?

您的控制器是“阶段路由任务”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM