Download file
In general, in the case of a format that can not interpret the response data of the server about the browser's HTTP GET/POST requests, the browser downloads the response as attachments.
If we want to get the file(as an attachment) that a browser will be able to interpreted as jpg, we depend on the the function(context menu Save As) of the browser itself or the response data must contain a header for ensuring the browser can download file forcely. The HTML5, regardless of the mime type, has an attribute to be able to download forced to file, but this funciton is not supported in all browsers, purely in the only client of the setting is not be able to download the file to disk.
DEXTUpload.NET Professional product is processing that the data can be downloaded directly as an attachment.
// The path of the resource is exposed. <a href="http://domain/path/Music/Beethoven/Moonlight.mp3">Beethoven Moonlight Sonata</a> // The "download.ashx" generic handler provides the download of the file with the 12345 key that points to the file to download, so that the target file can be downloaded, but the actual path is not exposed. <a href="http://domain/path/download.ashx?key=12345">Beethoven Moonlight Sonata</a>
In general, the proper circumstances using DEXTUpload.NET Professional product are the hiding the path of the target file or a file destination that has not been published to the Web service. So, in order to download the file, it must provide the aspx page or ashx a general handler that it is possible to download the file.
Using the "DEXTUpload.NET.FileDownload" class in order to download the file.
public class download : IHttpHandler { public void ProcessRequest(HttpContext context) { var key = context.Request.QueryString["key"] ?? string.Empty; // Gets the path to the file corresponding to key. // ... skip var file = new FileInfo("file path"); using (var dext = new FileDownload()) { dext.Download(file); } // Do not write data to the response using the "Response.Write" method after the download operation. } ... }
In the ASP.NET environment, when an attempt is made to obtain the binary data, not the aspx page, it is recommended that you use the ashx general handler. Otherwise it is often likely written superimposed download data because the aspx page has some tag for rendering HTML. Of course, if it is to delete all rest elements except for the aspx page indicator, you can write codes to download in aspx pages. But it may remain a part, such as the empty string by mistake developers, that the problem occurs sufficiently. Therefore, it has recommended not to use aspx page or a postback function for downloading.
DEXTUpload.NET Professional product do not provide any class to download files for ASP.NET MVC environment. you can use to download a file using the "System.Web.Mvc.FileContentResult" class instead.