【问题标题】:In an ashx file, can I set the filename of the returned file?在 ashx 文件中,我可以设置返回文件的文件名吗?
【发布时间】:2010-10-20 10:39:00
【问题描述】:

我的 ashx response.writes 会返回一个简单的文本文件。我可以更改文件名吗,所以如果我的 ashx 位于 mysite.com/someURL 它不会返回 someURL.txt 而是返回 myFileName.txt ?

【问题讨论】:

    标签: asp.net ashx


    【解决方案1】:

    您可以使用Content-Dispositionheaded 和Response.AddHeader 方法来设置下载文件的名称。

    context.Response.AddHeader("Content-Disposition", "attachment; filename=myFileName.txt");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 2014-08-28
      • 2013-04-15
      • 1970-01-01
      相关资源
      最近更新 更多