这是我的头脑
在routeConfig文件中,我有以下
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}/{title}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional, title = UrlParameter.Optional },
new[] {"xxx.Controllers"}
);
}
我正在使用名为EN
的区域和ENAreaRegistration.cs我有
public override string AreaName
{
get
{
return "EN";
}
}
public override void RegisterArea(AreaRegistrationContext routes)
{
routes.MapRoute(
"Menu",
"EN/{action}/{id}/{title}",
new { controller = "Category", action = "Index", id = 0, title = UrlParameter.Optional },
new[] { "xxx.Areas.EN.Controllers" }
);
routes.MapRoute(
"EN_default",
"EN/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "xxx.Areas.EN.Controllers" }
);
}
}
在视图上我有
@Html.ActionLink( item.Title, item.Title, "Category", new {id = item.id}, new {title = item.Title.Replace(" ", "-")} )
我正在尝试获取以下http://localhost:59295/EN/catergory/1/My-Careers
- 以便将id用于记录。
但我得到http://localhost:59295/EN/Category/My Career/1
我想使用id为1来显示记录,但所有它都是我的职业
请有人帮忙
谢谢
碎甲弹
答案 0 :(得分:0)
如果我理解我们的问题是正确的, ActionLink 应该是这样吗?
@Html.ActionLink( item.Title, item.Title, "Category",
routeValues: new {id = item.id, title = item.Title.Replace(" ", "-")},
htmlAttributes: null)