In My Page I have Used Link Button. On Click of that link button I am redirecting user to Corresponding Address where data is saved But Its working only in chrome in Firefox the extension of File is always .aspx
tenderDetail = BLLTender.GetTenderDetail(long.Parse(Request.QueryString["TenderID"])); var FileName = tenderDetail.TechDoc; if (File.Exists(Server.MapPath("Document/" + FileName))) { var path = Server.MapPath(Server.MapPath("Document/" + FileName)); var Extension = Path.GetExtension(path); var client = new WebClient(); var buffer = client.DownloadData(path); switch (Extension) { case ".docx": case ".doc": Response.ContentType = "Application/msword"; Response.AddHeader("content-length", buffer.Length.ToString(CultureInfo.InvariantCulture)); Response.BinaryWrite(buffer); break; case ".xlsx": case ".xls": Response.ContentType = "Application/x-msexcel"; Response.AddHeader("content-length", buffer.Length.ToString(CultureInfo.InvariantCulture)); Response.BinaryWrite(buffer); break; case ".pdf": Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString(CultureInfo.InvariantCulture)); Response.BinaryWrite(buffer); break; case ".zip": case ".rar": Response.ContentType = "application/zip"; Response.AddHeader("content-length", buffer.Length.ToString(CultureInfo.InvariantCulture)); Response.BinaryWrite(buffer); break; } }
var fileName = Request.QueryString["name"]; Response.Clear(); // Clear the content of the response Response.ClearContent(); Response.ClearHeaders(); // Buffer response so that page is sent // after processing is complete. Response.BufferOutput = true; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response.TransmitFile(Server.MapPath("~/Document/" + fileName)); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)