为什么呢?长度= 4被附加到我的URL中
本文关键字:我的 URL 长度 为什么呢 | 更新日期: 2023-09-27 18:31:39
我正在学习如何使用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>
我被难住了。有人知道了吗?
您使用的重载不正确。你拥有的是:
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