1
我的search
模型适用于我的MVC
应用程序。VaryByParam for MVC Model
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; }
}
现在,当用户搜索任何记录,这将通过model
数据传递选定PARAMS和我的GET请求如下:
[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);
}
如果传递的参数是一个string
或int
,我可以设置VaryByParam = "param"
或者如果有多个,它将与3210分开设置。但是,我如何缓存复杂的model
param?
谢谢@Alex .. :) –