public ActionResult DownloadAttachMent(long attachmentId) { try { if (!string.IsNullOrEmpty(Convert.ToString(attachmentId))) { var document = _attachments.GetAttachments(attachmentId); if (document != null) { var documentdetail = _attachments.GetAttachmentDetailsByAttachmentId(document.AttachmentId); return(File(documentdetail.AttachmentBytes, System.Net.Mime.MediaTypeNames.Application.Octet, document.AttachmentName)); } return(RedirectToAction("Dashboard", "AgentDashboard")); } else { return(RedirectToAction("Dashboard", "AgentDashboard")); } } catch (Exception) { throw; } }