Friday, June 20, 2025

How to download the file using transmitfile function in asp.net c#

 Response.ContentType = "application/pdf";

Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.pdf");

//MyFile.pdf should be present in Files folder on server. other wise it will show error file not found.

Response.TransmitFile(Server.MapPath("~/Files/MyFile.pdf"));

Response.End();


reference:-https://www.c-sharpcorner.com/UploadFile/afenster/how-to-download-a-file-in-Asp-Net/

No comments:

Post a Comment