我有一个导航栏,我想使用Html.ActionLink使用模型参数访问其他Action的GET方法。
控制器:
public ActionResult Balance(Users loggedUser)
{
return View(loggedUser);
}
目录 :
@Html.ActionLink("Add Balance", "Balance", "Home", new {model = Model.user}, new { @class = "navbar-brand" })
型
public class IndexViewModel
{
public Users user { get; set; }
public Balances balance { get;set; }
public Sells sell { get; set; }
public Purchases buy { get; set; }
public Rates lastRate { get; set; }
public List<Sells> allSells { get; set; }
public List<Purchases> allPurchases { get; set; }
}
先生,
你可以试试这个:
<a class="nav-link" asp-controller="home" asp-action="home" asp-route-[YOUR-ACTION-PARAMETER-NAME]="[YOUR-ACTION-PARAMETER]">Home</a>
例如:
<a class="nav-link" asp-controller="home" asp-action="home" asp-route-id="2">Home</a>
或
<a class="nav-link" asp-controller="home" asp-action="home" asp-route-search="sample">Home</a>