My action takes a model that looks like this:
public class ClassListVM { public ClassListVM() { Filter = new ClassFilterModel(); } public ClassFilterModel Filter { get; set; } public PagedList<Class> Classes { get; set; } } public class ClassFilterModel { public int? TermId { get; set; } public int? SubFormId { get; set; } public int? FormId { get; set; } } public ActionResult Index(ClassListVM model) { model.Classes = classService.GetClasses(model.Filter); return View(model); }
Now I want to generate the url: /Classes?Filter.SubFormId=1
. How to get the Filter
part in a URL using this code:
<a href="@Url.Action("Details", "Classes", new {Filter.TermId = Model.TermId, Filter.SubFormId = subForm.SubFormId})">go</a>
As you can see, Filter
cannot be used here.
source share