知道为什么找不到这个链接?
context.MapRoute(null, "Admin/CompanyUserDelete/{userprofileid}", new { controller = "Admin", action = "CompanyUserDelete", userprofileid = UrlParameter.Optional });
使用AreaRegistration类定义。
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(null, "Admin", new { controller = "Admin", action = "Index" });
context.MapRoute(null, "Admin/Users", new { controller = "Admin", action = "CompanyUsers" });
context.MapRoute(null, "Admin/Users/Create", new { controller = "Admin", action = "CreateUser" });
context.MapRoute(null, "Admin/Users/{userprofileid}", new { controller = "Admin", action = "CompanyUser" });
context.MapRoute(null, "Admin/CompanyUserDelete/{userprofileid}", new { controller = "Admin", action = "CompanyUserDelete", userprofileid = UrlParameter.Optional });
context.MapRoute(null, "Admin/Users/{userprofileid}/Photo", new { contro
ller = "Admin", action = "UserImage" });
}
</code></pre>
这是找不到的链接。
@Html.ActionLink("Delete", "CompanyUserDelete", "Admin", new { area = "Admin", userprofileid = userItem.UserProfileId }, null)
答案 0 :(得分:0)
CompanyUserDelete不会声明您要发送给它的第一个参数“area”。
context.MapRoute(null, "Admin/CompanyUserDelete/{userprofileid}", new { controller = "Admin", action = "CompanyUserDelete", userprofileid = UrlParameter.Optional });
但是你有“区域”
@Html.ActionLink("Delete", "CompanyUserDelete", "Admin", new { area = "Admin", userprofileid = userItem.UserProfileId }, null)