I'm trying to pass my model into Url.Action
:
@Model FilterVm
@Url.Action("Index", "Home", new { filter = @Model })
but when my method is called, I got always null in parameter
public ActionResult Index (FilterVm filter)
How can I pass my model as a parameter in 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
@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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.