download link for mobile
-
hi guys i want to give a download in asp.net for mobile this code is true for computer but in mobile not true in computer show download form but in mobile show the content of file such as a html page open page a txt file show content of file a zip file show binery code and such whats problem
-
hi guys i want to give a download in asp.net for mobile this code is true for computer but in mobile not true in computer show download form but in mobile show the content of file such as a html page open page a txt file show content of file a zip file show binery code and such whats problem
my code is
{ string filepath = Server.MapPath("test.bhd"); FileInfo file = new FileInfo(filepath); if (file.Exists) { Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = ReturnExtension(file.Extension.ToLower()); Response.TransmitFile(file.FullName); Response.End(); } } private string ReturnExtension(string fileExtension) { switch (fileExtension) { case ".htm": case ".html": case ".log": return "text/HTML"; case ".txt": return "text/plain"; case ".doc": return "application/ms-word"; case ".tiff": case ".tif": return "image/tiff"; case ".asf": return "video/x-ms-asf"; case ".avi": return "video/avi"; case ".zip": return "application/zip"; case ".xls": case ".csv": return "application/vnd.ms-excel"; case ".gif": return "image/gif"; case ".jpg": case "jpeg": return "image/jpeg"; case ".bmp": return "image/bmp"; case ".wav": return "audio/wav"; case ".mp3": return "audio/mpeg3"; case ".mpg": case "mpeg": return "video/mpeg"; case ".rtf": return "application/rtf"; case ".asp": return "text/asp"; case ".pdf": return "application/pdf"; case ".fdf": return "application/vnd.fdf"; case ".ppt": return "application/mspowerpoint"; case ".dwg": return "image/vnd.dwg"; case ".msg": return "application/msoutlook"; case ".xml": case ".sdxl": return "application/xml"; case ".xdp": return "application/vnd.adobe.xdp+xml"; default: return "application/octet-stream"; } }