HTML.ActionLink 详细信息页面无法正常工作

HTML.ActionLink to details page not working

您好,我在解决这个问题时遇到了问题。我希望我的 header 成为重定向到详细信息的 link

<div class="card-columns">
    @foreach (var item in Model)
    {
        <div class="card" style="width:300px">
            <img class="card-img-top" src=@Html.DisplayFor(modelItem => item.CoverArt) alt="Card image">
            <div class="card-body">
                @Html.ActionLink(modelItem => item.Name, "Details", "Albums", new { /* id=item.PrimaryKey */ }, null)
                <p class="card-text">@Html.DisplayFor(modelItem => item.Info)</p>
                <p class="card-text small">@Html.DisplayFor(modelItem => item.ReleaseDate)</p>
            </div>
        </div>
    }
</div>

我在网上找到了这个,但它抛出了一个错误:

'There is no argument given that corresponds to the required forma parameter 'fragment' of 'IHtmlHelper.ActionLink(string, string,.....)'

modelItem => item.Name替换为item.Name

<div class="card-columns">
    @foreach (var item in Model)
    {
        <div class="card" style="width:300px">
            <img class="card-img-top" src=@Html.DisplayFor(modelItem => item.CoverArt) alt="Card image">
            <div class="card-body">
                @Html.ActionLink(item.Name, "Details", "Albums", new { /* id=item.PrimaryKey */ }, null)
                <p class="card-text">@Html.DisplayFor(modelItem => item.Info)</p>
                <p class="card-text small">@Html.DisplayFor(modelItem => item.ReleaseDate)</p>
            </div>
        </div>
    }
</div>

我用过这个并且有效:

<a asp-action="Details" asp-route-id="@item.Id">
  <h4 class="card-title">
    @item.Name
  </h4>
</a>