Kurwaii
Kurwaii
CC#
Created by Kurwaii on 12/7/2023 in #help
C# redirect after sending file through headers
Using the code below I am getting an error, can't redirect after setting headers, is there any work around so that I can redirect to the page after the user downloads the file?
// Prepare the file content byte[] fileBytes = excelPackage.GetAsByteArray(); // Disable buffering to send the headers immediately Response.BufferOutput = false; // Set the response headers for the file download Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("Content-Disposition", "attachment; filename=CredenciaisPrestadores.xlsx"); // Send the file content without flushing Response.BinaryWrite(fileBytes); // Perform any other actions before the redirect here // Now, enable buffering and flush the response to initiate the file download Response.BufferOutput = true; Response.Flush(); // Redirect after the response has been sent return RedirectToAction("Details", new { Id = id });
6 replies
CC#
Created by Kurwaii on 11/8/2023 in #help
❔ Issue with nuget package
No description
8 replies
CC#
Created by Kurwaii on 11/8/2023 in #help
❔ Issue deploying to server
No description
18 replies