我想通过我的模型到Url.Action
:如何通过引用类型为Url.Action
@Model FilterVm
@Url.Action("Index", "Home", new { filter = @Model })
但是当我的方法被调用时,我得到了参数
public ActionResult Index (FilterVm filter)
总是空如何将我的模型作为Url.Action中的参数传递?
我想通过我的模型到Url.Action
:如何通过引用类型为Url.Action
@Model FilterVm
@Url.Action("Index", "Home", new { filter = @Model })
但是当我的方法被调用时,我得到了参数
public ActionResult Index (FilterVm filter)
总是空如何将我的模型作为Url.Action中的参数传递?
您需要分别传递模型的所有字段。 例如,如果你的模型包含2个字段的名称和ID Url.Action必须
@Url.Action("Index", "Home", new { Name=Model.Name, Id=Model.Id })
而且模型声明在你看来需要小写
@model FilterVm
你不需要单独传递它们。 '@ Url.Action(“Index”,“Home”,new {Model}'很好, –
非常感谢,不幸的是我不能给你一个满意的答案,因为我需要15个声望,但是也许我能够做到这一点后来 –
我现在可以做了,再次感谢 –
什么是指数行动签名?它需要什么参数? – Christos
请阅读第5行中的问题 –
仅仅是@ @ Url.Action(“Index”,“Home”,new {Model})',但它只有在模型只包含简单属性时才有效(集合的复杂属性将不会绑定) –