我的操作接受一个模型,看起来像这样:
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);
}
现在我想生成这样的URL:
/Classes?Filter.SubFormId=1
。使用以下代码,如何将Filter
部分放入URL中:<a href="@Url.Action("Details", "Classes", new {Filter.TermId = Model.TermId, Filter.SubFormId = subForm.SubFormId})">go</a>
正如您所看到的,这里无法使用Filter
。