Asp.net 如何路由IdentityUser(如用户名)的值而不是整个对象?

Asp.net 如何路由IdentityUser(如用户名)的值而不是整个对象?,asp.net,asp.net-mvc,asp.net-core,Asp.net,Asp.net Mvc,Asp.net Core,所以我的观点如下: @model List<ListUsers> <div class="card-deck"> @foreach (var user in Model) { <div class="card m-3" style="min-width: 18rem; max-width:30.5%"> <div class="card-header">

所以我的观点如下:

@model List<ListUsers>



<div class="card-deck">
    @foreach (var user in Model)
    {
        <div class="card m-3" style="min-width: 18rem; max-width:30.5%">

            <div class="card-header">
                <h5>@user.FriendId</h5>
            </div>

            <div class="card-body">
                <h2>@user.FriendName</h2>
            </div>


            <div class="card-footer text-center">
                <a asp-controller="account" asp-action="showprofile" asp-route-id="@user"
                   class="btn btn-primary">ShowProfile</a>
            </div>
        </div>
    }
</div>

(我可以在浏览器页面的源代码中看到ID被附加在url中)它将整个IdentityUser对象交给相应的actionmethod。我只想要那根绳子

这也不行

"asp-route-id="@user.FriendId.ToString()"

谢谢大家!

首先确认FriendId的字段类型,在showprofile操作中接收参数的
相同类型
,然后接收变量名为
“id”
的参数

    public IActionResult showprofile(int id)//if it is string type,use 'string id' to receive
    {
       // do what you want 
        return View();
    }

您还可以参考。

您还需要使用showprofile操作方法显示您的帐户管理员哇,谢谢。我不知道它必须与参数“id”一起接收,我认为它可以被称为任何东西。我被困在这几个小时了,谢谢!!!!!
    public IActionResult showprofile(int id)//if it is string type,use 'string id' to receive
    {
       // do what you want 
        return View();
    }