【问题标题】:why is ?Length=4 being appended to my URL's为什么 ?Length=4 被附加到我的 URL 中
【发布时间】:2013-09-22 18:33:42
【问题描述】:

我正在学习如何使用 Visual Studio Express 2012。为此,我将常规网站(个人)转换为 ASP.NET C# 网站。但是,我遇到了一个我无法解决的问题。 ?Length=4 被自动附加到我的 URL 中,但我找不到源。

我的Html.ActionLink代码如下:

<div class="navpane">@Html.ActionLink(" ", "About", "Home", new {style="background: url('../images/sticky-who.png') no-repeat; display:block; height:150px; width:150px;"})</div>

<div class="navpane">@Html.ActionLink(" ", "Resume", "Home", new {style="background: url('../images/sticky-resume.png') no-repeat; display:block; height:150px; width:150px;"})</div>

我被难住了。有人有线索吗?

【问题讨论】:

标签: c# asp.net html visual-studio-2012 web


【解决方案1】:

您使用了不正确的重载。你所拥有的是:

Html.ActionLink(string, string, string, object)

..解析为:

Html.ActionLink(string, string, object, object)

这是:

Html.ActionLink(string linkText, string actionName, Object routeValues, Object htmlAttributes)

你需要使用这个重载:

Html.ActionLink(string linkText, string actionName, string controllerName, Object routeValues, Object htmlAttributes)

htmlAttributes 在最后。您当前将routeValues 传递为"Home".. 因此Length=4

试试这个:

@Html.ActionLink(" ", "About", "Home", null, new {style="background: url('../images/sticky-who.png') no-repeat; display:block; height:150px; width:150px;"})
//                                     ^^^^ The important part

【讨论】:

    猜你喜欢
    • 2015-01-12
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 2010-10-23
    • 2011-02-17
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    相关资源
    最近更新 更多