My action accepts a model that looks like the following:
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 a url like this: /Classes?Filter.SubFormId=1. How do I get the Filter part into the 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.
Theoretically, you can build it this way:
Something like that; essentially, embed the query string into the client markup, and inject in only the parameters.