如何创建转到Controller / Action / Id / Application的链接?
我试过
@Html.ActionLink("link", "action", "controller", new { Id = @Model.Id }, new { application = @application.Name})
答案 0 :(得分:1)
首先,您需要在App_Start/RouteConfig.cs
类似的东西:
routes.MapRoute(
name: "RouteName",
url: "{controller}/{action}/{id}/{application}",
defaults: new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
application = UrlParameter.Optional
});
然后,生成网址:
@Html.ActionLink("link", "action", "controller", new { id = @Model.Id, application = @application.Name})