I'm trying to download a user to Response.TransmitFile () user. I have read many posts on this issue and Rick Stryhal's blog is based on my own method
The only difference (which I can tell) is that I am targeting a physical file outside the virtual directory . This code is called in an acidified radrid ... I wonder how the reaction. Transmission file does not work with AJAX calls? Here is my code snippet:
// get the physical path of file string docFilePath = (string) args.AttachmentKeyValues ["DocFilePath"]; // FileInfo file = New FileInfo (docFilePath) Create a new instance of FileInfo class to get the properties of the file to be downloaded; // Checking if file exists (file.Exists) {Response.ClearContent (); Response.AddHeader ("content-dispute", "attachment; filename =" + file.Name); Response.AddHeader ("content-length", file-length.tostring ()); Response. Contact Type = Return Extension (File Extension. Too Lover ()); Response.TransmitFile (file.FullName); Response.End (); }
The system knows that the file exists ... it answers without any errors. Transmits ... so the app continues properly ... except that there is no download prompt.
String Return Extension (string file extension) {// Long time it should go to a class switch (file extension) {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 / AV"; Case ".zip": return "app / 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": Refund "Application / MSPEPoint"; 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"; }}
The problem is that I can not react with an AJAX. Pu ka ra no After reading some blogs, I use async postback to set the src of an invisible iframe. Iframe then sends the file to its load event.
Comments
Post a Comment