public ActionResult ClassTermWiseMarks() { string classname = ReportsController.classname; if (classname == "All") { return(RedirectToAction("AdminReportsOnly", "Reports")); } int classid = 1; int termid = 0; DB37Entities db = new DB37Entities(); classid = db.Classtbls.Where(t => t.Section == ReportsController.classname).FirstOrDefault().Id; termid = db.Termstbls.Where(t => t.Name == ReportsController.termname).FirstOrDefault().Id; //CrMVCApp.Models.Customer c; var c = db.TermWiseMarksOfAClass(classid, termid).ToList(); TermWiseMarks rpt = new TermWiseMarks(); rpt.Load(); rpt.SetDataSource(c); Stream s = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s, "application/pdf")); }