Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 具有两个输入参数的ASP.NET mvc锚定标记帮助器_Asp.net Mvc_Visual Studio 2015_Asp.net Core Mvc_Tag Helpers - Fatal编程技术网

Asp.net mvc 具有两个输入参数的ASP.NET mvc锚定标记帮助器

Asp.net mvc 具有两个输入参数的ASP.NET mvc锚定标记帮助器,asp.net-mvc,visual-studio-2015,asp.net-core-mvc,tag-helpers,Asp.net Mvc,Visual Studio 2015,Asp.net Core Mvc,Tag Helpers,在我的ASP.NET MVC Core 1.1项目中,我需要传递两个参数——一个用于id,一个用于customerNumber。对于通过id,我知道我可以使用asp路由id。如何对customerNumber执行相同操作: 部分视图: .... @foreach (var item in Model.lstCustomers) { <tr> <td><a asp-action="Index" asp-route-id="@item.CustomerID

在我的ASP.NET MVC Core 1.1项目中,我需要传递两个参数——一个用于id,一个用于customerNumber。对于通过id,我知道我可以使用
asp路由id
。如何对customerNumber执行相同操作:

部分视图

....
@foreach (var item in Model.lstCustomers)
{
  <tr>
     <td><a asp-action="Index" asp-route-id="@item.CustomerID">@item.CustomerName</a></td>
  </tr>
...
}
。。。。
@foreach(Model.lstCustomers中的var项)
{
@item.CustomerName
...
}

使用与ID相同的方法

asp路由参数
必须与控制器方法中的参数匹配

....
@foreach (var item in Model.lstCustomers)
{
  <tr>
     <td><a asp-action="Index" asp-route-id="@item.CustomerID" asp-route-customerNumber="@item.customerNumber">@item.CustomerName</a></td>
  </tr>
...
}
。。。。
@foreach(Model.lstCustomers中的var项)
{
@item.CustomerName
...
}

使用与ID相同的方法

asp路由参数
必须与控制器方法中的参数匹配

....
@foreach (var item in Model.lstCustomers)
{
  <tr>
     <td><a asp-action="Index" asp-route-id="@item.CustomerID" asp-route-customerNumber="@item.customerNumber">@item.CustomerName</a></td>
  </tr>
...
}
。。。。
@foreach(Model.lstCustomers中的var项)
{
@item.CustomerName
...
}

感谢您提到
asp路由参数必须与控制器方法中的参数匹配
。这是您建议的解决方案的一个关键点。感谢您提到
asp路由参数必须与控制器方法中的参数匹配。这是你建议的解决方案的一个关键点。