We have the following Controller for getting file:
[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);
}
}
It's OK and works well but it doesn't work with ImageResizer API
e.g:
The following image shows in natural size(1920*1200) and maxwidth or maxheight doesn't work at all. But if I use the absolute file path it works.
<img src="File/Index/1231?maxwidth=300&maxheight=300" alt="" />