Friday, July 17, 2009

Download file from server using Response.TransmitFile

hi.
we can user Response.TransmitFile to Allow users to download file.
here is the code to download file.You have to change Response.ContentType attribute as per type of your content.

Here is the sample code.

if (File.Exists(FilePath))
{
Response.ContentType = "image/jpeg"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + "FileName.jpeg"); Response.TransmitFile(FilePath);
Response.End();
}

Thanks.

No comments:

Post a Comment

Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author