locked
Sending pdf file to Client (Download pdf functionality in asp.net) RRS feed

  • Question

  • User1140748964 posted

    Hi All,

    I have follwoing scenario. I want to download pdf file.  I have one folder which some local macine. This folder contains the pdf files and only one person is given access write to that folder. All i need to do is impersonate the user and download the pdf from this folder. So i am using Response.TransmitFile Method of http object. I am sucessfully able to impersonate the user whoever logs on to the site and send a file to client.  But i am not sure if Response.TransmitFile is the correct and right way to go for it. I am passing the pdf file directly in the Response.TransmitFile Method. Is this Correct way to go for it ?? Will it affect the functionality ??. Most of the posts i visited are using the same method. But i still need to confirm if its the efficient and safe method for sending file to client.  I am using VS2005 and ASP.Net 2.0.

    Could you please help me on this ?

    Any help on this would be highly appreciated.

     Thanks,

    Amruta

    Thursday, December 11, 2008 11:40 AM

Answers

  • User-1171043462 posted

    Use the following 

    Response.AppendHeader(
    "content-disposition", "attachment; filename=" & strFileName)

    Response.WriteFile(strFilePath + strFileName)

    Response.End()

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 11, 2008 11:51 AM