[SessionState(SessionStateBehavior.Disabled)] public class FileController : BaseController { [HttpGet] public FileResult Index(long id) { if (id <= 0) return null; Attachment attachment = Service.GetAttachmentById(id); if (attachment == null) return null; new Task(() => Service.IncreaseAttachmentViewCount(id)).Start(); string filename = attachment.Name; //"application/octet-stream"; string mimeType = System.Web.MimeMapping.GetMimeMapping(filename); return File(attachment.Path, mimeType); } }
<img src="File/Index/1231?maxwidth=300&maxheight=300" alt="" />
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)