public ActionResult ViewAttachment(int attachementId, bool?download) { using (WorkFlowApiClient client = new WorkFlowApiClient()) { WF_FlowCases_Attachments attach = WFEntities.WF_FlowCases_Attachments.FirstOrDefault(p => p.StatusId > 0 && p.AttachementId == attachementId); if (attach != null) { try { string contenttype = HtmlUIHelper.GetContentType(attach.FileName); byte[] bytes = client.GetAttachmentFile(attach.AttachementId); if (download == true || string.IsNullOrWhiteSpace(contenttype)) { return(File(bytes, attach.OriFileName)); } Response.AppendHeader("Content-Disposition", "filename=" + attach.OriFileName); return(File(bytes, contenttype)); } catch (Exception e) { return(Content(StringResource.ATTACHMENT_NOT_FOUND)); } } } return(Content(StringResource.ATTACHMENT_NOT_FOUND)); }
public ActionResult ViewUploaded(string filename, string display, bool?download) { string dir = Server.MapPath("~/temp/app"); string contenttype = HtmlUIHelper.GetContentType(filename); if (download == true || contenttype == null) { return(File(Path.Combine(dir, filename), "application/octet-stream", display)); } Response.AppendHeader("Content-Disposition", "filename=" + (display ?? filename)); return(File(Path.Combine(dir, filename), contenttype)); }