ev *_* vk 2 model-view-controller asp.net-mvc bootstrap-4
你好,我正在使用 bootstrap 4.0,
我的导航栏有这个代码
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
@Html.ActionLink("Manage assistants", "Index", "Assistant", new { @class = "nav-link" })
</li>
....
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我尝试重定向到 Assistantcontroller/index 时,导航栏链接重定向到 localhostxxx/?lenght=8
这里发生了什么?我错过了什么吗?
谢谢
小智 5
您使用此重载,其中第三个参数是routeValues
值。
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
object routeValues,
object htmlAttributes
)
Run Code Online (Sandbox Code Playgroud)
因为您传递了一个string
, 并且一个字符串有一个属性名称Length
,所以它会生成?lenght=8
一个查询字符串(虽然我假设您有一个错字,因为“助手”包含 9 个字符,所以它会生成?length=9
)
改变你的方法
@Html.ActionLink("Manage assistants", "Index", "Assistant", null, new { @class = "nav-link" })
Run Code Online (Sandbox Code Playgroud)
以便您使用此重载
public static MvcHtmlString ActionLink(
this HtmlHelper htmlHelper,
string linkText,
string actionName,
string controllerName,
object routeValues,
object htmlAttributes
)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1208 次 |
最近记录: |