Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

asp.net

ashx

My ashx response.writes a simple 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 ?

like image 627
NibblyPig Avatar asked Oct 20 '10 10:10

NibblyPig


1 Answers

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");
like image 107
iburlakov Avatar answered Oct 28 '22 12:10

iburlakov