protected void Page_Load(object sender, EventArgs e) { Response.ClearHeaders(); }
public void DownloadFile(string fileName, string mimeType, byte[] fileBytes) { Response.ClearHeaders(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=" + fileName); Response.BinaryWrite(fileBytes); Response.End(); }In this example, the ClearHeaders method is called before setting the response content type and adding a content-disposition header for the file download. This ensures that any existing headers are removed before adding the necessary ones for the file download. Package library: System.Web.