public ActionResult StudentInfo() { string studentreg = ReportsController.studentreg; int studentid = 1; DB37Entities db = new DB37Entities(); if (db.Studentstbls.Any(t => t.RegistrationNumber == studentreg)) { studentid = db.Studentstbls.Where(t => t.RegistrationNumber == studentreg).FirstOrDefault().Id; } else { ViewBag.warn = "Invalid Student Registration Number"; return(RedirectToAction("AdminReportsOnly")); } //CrMVCApp.Models.Customer c; var c = db.ShowStudentInfo(studentid).ToList(); StudentInfo rpt = new StudentInfo(); rpt.Load(); rpt.SetDataSource(c); Stream s = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(s, "application/pdf")); }