I have below search
model for my MVC
application.
public class SearchFilters
{
public SearchFilters()
{
MinPrice = "10000";
MaxPrice = "8000000";
}
public IEnumerable<SelectListItem> Categories { get; set; }
public string[] CategoriesId { get; set; }
public IEnumerable<SelectListItem> Locations { get; set; }
public string[] LocationID { get; set; }
public IEnumerable<SelectListItem> Status { get; set; }
public string[] StatusID { get; set; }
public string MinPrice { get; set; }
public string MaxPrice { get; set; }
}
Now when the user searches for any record, It will pass the selected params through model
data and my get request is as below:
[HttpGet]
public ActionResult Search([Bind(Prefix = "searchModel")]SearchFilters smodel)
{
CategoryViewModel model = new CategoryViewModel();
model = _prepareModel.PrepareCategoryModel("Search", smodel);
if (model.projects.Count == 0)
{
return Json(new { message = "Sorry! No result matching your search", count = model.projects.Count }, JsonRequestBehavior.AllowGet);
}
return PartialView("_CategoryView", model);
}
If the parameter passed was a string
or int
, I could have set VaryByParam = "param"
or if multiple it would be set with ';'
separated values. But how would I cache the complex model
param here?