public ActionResult GeneratePdf() { string _message; var listOfSgv = db.ScalableVectorGraphics.ToList(); if (listOfSgv.Any()) { try { var stream = _pdfService.MultipleItems(listOfSgv); return(File(stream, "application/pdf", "svgList.pdf")); } catch (Exception ex) { _message = ex.Message; } } else { _message = "PDF can not be generated bacause your table contains no items"; } return(RedirectToAction("Index", "ScalableVectorGraphics", new { message = _message })); }