NibblyPig
NibblyPig

Reputation: 52952

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

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 ?

Upvotes: 7

Views: 3464

Answers (1)

iburlakov
iburlakov

Reputation: 4232

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");

Upvotes: 16

Related Questions