0
我有这个在我的Global.asax.cs不是渲染:@ Html.ActionLink按预期
routes.MapRoute(
"User",
"User/{username}/{action}",
new { controller = "User", action = "Index", username = "*" }
);
然后在我的_Layout.cshtml我有这样的代码:
<ul id="menu">
@if (!String.IsNullOrEmpty(Context.User.Identity.Name))
{
<li>@Html.ActionLink("Home", "Home", new { controller = "User" }, new { username = Context.User.Identity.Name })</li>
}
</ul>
</div>
</div>
的东西是,它会在第一次在这里摆动时正确显示链接。 (链接将会是/ User/rob/Home,其中“rob”是一个用户名,如果我在页面的其他地方导航,然后点击我的链接,链接将显示为/ User/*/Home。码,Context.User.Identity.Name每次是正确的。
我失去了真正的基本的东西吗?我不知道该怎么寻找。
尝试将此添加到页面<%= Context.User.Identity.Name%>并查看会发生什么。 – Iain 2010-11-29 02:22:44
我不确定你正在使用什么ActionLink重载,这里是我认为应该是的:Html.ActionLink(“Home”,“Home”,“User”,new {username = Context.User.Identity.Name} ,新{}) – Iain 2010-11-29 02:28:20