public string DownloadAttachment() { string filepath = new FileInfo(HttpContext.Current.Server.MapPath("Ticket")).FullName +"\\"+ GetPageParams<string>("hdnAttachmentID"); string fileExtension = Path.GetExtension(GetPageParams<string>("hdnAttachmentID")); string viewname = "TicketUpdateDetailView"; try { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.WriteFile(filepath); switch (fileExtension) { case ".jpg": case ".jpeg": { HttpContext.Current.Response.ContentType = "image/jpeg"; HttpContext.Current.Response.AppendHeader("Content-disposition", "inline;filename=" + Path.GetFileName(filepath)); break; } case ".bmp": { HttpContext.Current.Response.ContentType = "image/bmp"; HttpContext.Current.Response.AppendHeader("Content-disposition", "inline;filename=" + Path.GetFileName(filepath)); break; } case ".gif": { HttpContext.Current.Response.ContentType = "image/gif"; HttpContext.Current.Response.AppendHeader("Content-disposition", "inline;filename=" + Path.GetFileName(filepath)); break; } case ".png": { HttpContext.Current.Response.ContentType = "image/png"; HttpContext.Current.Response.AppendHeader("Content-disposition", "inline;filename=" + Path.GetFileName(filepath)); break; } default: { HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=" + Path.GetFileName(filepath)); break; } } //HttpContext.Current.Response.ContentType = "application/octet-stream"; //HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(fileFullPath)); //var pageTitle = (Page)HttpContext.Current.Handler; //pageTitle.Title=Path.GetFileName(fileFullPath); HttpContext.Current.Response.End(); viewname = "TicketUpdateDetailView"; } catch (System.Threading.ThreadAbortException ex1) { } catch (Exception ex) { } return viewname; }
Title
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)