簡體   English   中英

如何將引用類型傳遞給Url.Action

[英]How to pass reference type into Url.Action

我正在嘗試將我的模型傳遞給Url.Action

@Model FilterVm
@Url.Action("Index", "Home", new { filter = @Model })

但是當我的方法被調用時,參數總是為null

public ActionResult Index (FilterVm filter)

如何在Url.Action中將模型作為參數傳遞?

您需要分別傳遞模型的所有字段。 例如,如果您的模型包含2個字段,則Name和Id Url.Action必須為

@Url.Action("Index", "Home", new { Name=Model.Name, Id=Model.Id })

另外,您認為模型聲明必須小寫

@model FilterVm

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM