我有以下控制器,在该控制器中我创建了会话来保存IENUMERABLE
数据集
[HttpPost]
[ValidateInput(false)]
public ActionResult Create_Brochure(IEnumerable<ProductsPropertiesVM> model)
{
IEnumerable<ProductsPropertiesVM> newmodel = model;
IEnumerable<BrochureTemplateProperties> sample = model.Where.....
Session["TemplateData"] = newmodel;
return View(sample);
}
EDIT:
Create_Brchure View页面有href链接可以调用PrintIndex
同一类文件中的方法
<a href="@Url.Action("PrintIndex", "Brochure")">Download ViewAsPdf</a>
this is PrintIndex
method
public ActionResult PrintIndex()
{
return new Rotativa.ActionAsPdf("Create_Brochure_PDF") { FileName = "TestActionAsPdf.pdf" };
}
我想再次使用该会话列表数据集Create_Brochure_PDF
控制器方法,所以我在这里创建了该方法
public ActionResult Create_Brochure_PDF()
{
IEnumerable<ProductsPropertiesVM> newmodel = Session["TemplateData"] as IEnumerable<ProductsPropertiesVM>;
IEnumerable<BrochureTemplateProperties> samplePDF = newmodel.Where(....
return View(samplePDF);
}
但在上面的方法中我得到了 nullIEnumerable<ProductsPropertiesVM> newmodel
EDIT:
如果我解释一下整个场景
-
Create_Brochure
控制器方法有一个视图,
- 在该视图中,我有 href 链接来保存它
Create_Brochure
查看为PDF
- 单击该 href 链接后,我将调用
PrintIndex
方法如此
该操作方法再次调用Create_Brochure_PDF
方法 ,
所以我得到了空对象集Create_Brochure_PDF