[英]How to pass reference type into Url.Action
I'm trying to pass my model into Url.Action
: 我正在尝试将我的模型传递给Url.Action
:
@Model FilterVm
@Url.Action("Index", "Home", new { filter = @Model })
but when my method is called, I got always null in parameter 但是当我的方法被调用时,参数总是为null
public ActionResult Index (FilterVm filter)
How can I pass my model as a parameter in Url.Action? 如何在Url.Action中将模型作为参数传递?
You need to pass all fields of your model separately. 您需要分别传递模型的所有字段。 For example, if your model contain 2 fields Name and Id Url.Action must be 例如,如果您的模型包含2个字段,则Name和Id Url.Action必须为
@Url.Action("Index", "Home", new { Name=Model.Name, Id=Model.Id })
Also Model declaration in your view need to be in lower case 另外,您认为模型声明必须小写
@model FilterVm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.