Logout for Logout呈现错误的路径

时间:2015-08-07 17:26:51

标签: asp.net-mvc

我想弄清楚为什么我的ActionLink出错了。在我的_Layout.cshtml中我有

<div class="col-sm-7">
    <ul>
        <li class="section-head section-head2 ">XYZ Technologies</li>
        <li>@ViewBag.Email</li>
    </ul>
</div>
<div class="col-sm-5">
    @Html.ActionLink("Logout", "LogOut", "Submission", new {@class = "pull-right"})
</div>

但是,当我在“自定义”控制器的视图中时,它呈现如下:

<div class="col-sm-7">
    <ul>
        <li class="section-head section-head2 ">XYZ Technologies</li>
        <li>someone@noserver.com</li>
</div>
<div class="col-sm-5">
    <a class="pull-right" href="/customforms/logout?Length=10">Logout</a>
</div>

我猜有些东西会覆盖它,但我不确定如何追踪它。有什么想法吗?

2 个答案:

答案 0 :(得分:1)

Length = 10来自尝试序列化与“提交”有10个字符的字符串对象。您可以将其更改为

@Html.ActionLink("Logout", "LogOut", new { controller = "Submission" }, new {@class = "pull-right"})

实际上,“ActionLink”将其视为“routeValues”参数。

答案 1 :(得分:0)

你在actionlink helper中指定路由值..设置你需要为路由对象param添加null的html属性

 @Html.ActionLink("Logout", "LogOut", "Submission", null, new { @class = "pull-right" })