如何在下面做一个动态href?

How to do a dynamic href below?

如何做下面的动态href?

@Model.inbox_type 是动态值“1”、“2”、“3” .. “6”,如何使用下面的 href 应用它?

<button class="btn btn-block btn-secondary" type="button" onclick="location.href='@Url.Action("Index/" + "@Model.inbox_type" , "Inbox")'">Exit</button>

您可以在 Url.Action 上传递参数而不是字符串附加

<button class="btn btn-block btn-secondary" type="button" onclick="location.href='@Url.Action("Index", "Inbox", new { id: @Model.inbox_type })'">Exit</button>

请注意,id 是您在操作函数中期望的参数

public ActionResult Index(string id) 

您可以查看this document以供参考