名为"Home_default2"的路径已在路径集合中.路线名称必须是唯一的.
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
name: "Default",
url: "area/{controller}/{action}/{id}",
defaults: new {area="Home_Default", controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
public override string AreaName
{
get
{
return "Home";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Home_default2",
"Home/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud)
自动生成的代码是错误的,我做错了什么?
我想在我的内部实现一个菜单 _Layout.cshtml视图中:
@Html.Partial("_LoginPartial")
@{ Html.RenderAction("Index", "Home"); }
@if (@ViewBag.Menus != null)
{
foreach (vw_UsuarioPerfilMenuFuncionalidade memo in @ViewBag.Menus)
{
if (memo.IdMenuLast == null)
{
<li><span>@memo.NomeMenu</span></li>
foreach (vw_UsuarioPerfilMenuFuncionalidade memo2 in @ViewBag.Menus)
{
if (memo.IdMenu == memo2.IdMenuLast)
{
<li><span>@memo2.NomeMenu</span></li>
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我加载页面时,System.StackOverflowException抛出一个:
System.Web.dll中发生了未处理的"System.StackOverflowException"类型异常
这是为什么?