Change name of file sent to client?

后端 未结 4 1319
说谎
说谎 2020-12-17 23:22

I have a webpage that pulls information from a database, converts it to .csv format, and writes the file to the HTTPResponse.

string csv = GetCSV();
Respon         


        
相关标签:
4条回答
  • 2020-12-17 23:31

    I believe this will work for you.

    Response.AddHeader("content-disposition", "attachment; filename=NewFileName.csv");
    
    0 讨论(0)
  • 2020-12-17 23:48

    You just need to set the Content-Disposition header

    Content-Disposition:  attachment; filename=data.csv
    

    This Microsoft Support article has some good information

    How To Raise a "File Download" Dialog Box for a Known MIME Type

    0 讨论(0)
  • 2020-12-17 23:48

    Add a "Content-Disposition" header with the value "attachment; filename=filename.csv".

    0 讨论(0)
  • 2020-12-17 23:52
    Response.AddHeader("content-disposition", "attachment; filename=File.doc")
    
    0 讨论(0)
提交回复
热议问题