我正在 asp.net mvc 中開發一個應用程式,我想創建一個 url(您將在下面看到)。
我已經看到有這個問題@Html.ActionLink 以專案名稱作為鏈接 ,不能滿足我的需求
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Data)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.NextTurnPlayer)
</td>
<td>
@Html.DisplayFor(modelItem => item.State)
</td>
<td>
@if(item.State.Equals("Conclusa")){
@Html.DisplayFor(modelItem => item.Winner)
}
</td>
<!--se non c'è neancora il secondo giocatore e il giocatore non è quello che ha creato la partita mostro partecipa-->
@if(item.UsernamePlayer2 == null && item.UsernamePlayer1 != HttpContext.Current.User.Identity.Name){
<td>
@Html.ActionLink("Partecipate", "Partecipate", "Manage", new { Id= (string) @item.Name}, null)
</td>
}<!--se non ci sono entrambi giocatori e il giocatore loggato fa parte del match mostro gioca-->
@if(item.UsernamePlayer2 != null && (item.UsernamePlayer1 == HttpContext.Current.User.Identity.Name || item.UsernamePlayer2 == HttpContext.Current.User.Identity.Name)){
<td>
@Html.ActionLink("Play!", "Game", "Manage", new { Id= (string) @item.Name}, null)
</td>
}
</tr>
}
它給了我以下網址:
https://localhost:44398/Manage/Partecipate/Ciao
但我想擁有
https://localhost:44398/Manage/Partecipate?Name=Ciao
uj5u.com熱心網友回復:
您是否嘗試將路由引數名稱更改為Name?
@Html.ActionLink("Partecipate", "Partecipate", "Manage", new { Name = item.Name}, null)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/483050.html
標籤:C# 网 asp.net-mvc 数据库
