开发者

In an ashx file, can I set the filename of the returned file?

开发者 https://www.devze.com 2023-01-21 16:28 出处:网络
My ashx response.writes a s开发者_StackOverflow社区imple text file that is returned. Can I change the filename, so if my ashx is located at mysite.com/someURL it doesn\'t return someURL.txt but rather

My ashx response.writes a s开发者_StackOverflow社区imple text file that is returned. Can I change the filename, so if my ashx is located at mysite.com/someURL it doesn't return someURL.txt but rather, myFileName.txt ?


You can use Content-Disposition headed and Response.AddHeader method for setting name of downloaded file.

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号