"Mark Rendle" <markdotrendleatcomputersoftwaredotcom> wrote in message news:ue*************@tk2msftngp13.phx.gbl...
setting ContentType to "text/csv", except when the "Open/Save" dialog appears, the filename shown is "ExportRun.aspx". Is there
any way I can change this to, e.g., "mydata.csv" without having to generate a temporary file on the server?
Mark,
You need to call AddHeader( ) on the Response to add the "Content-Disposition"
HTTP header and specify a filename (its not one of the standard HTTP headers
that ASP.NET exposes as a property on the HttpResponse class so you have to
use this general-purpose add-a-header method),
Response.AddHeader( "Content-Disposition",
String.Format( "attachment; filename=\"{0}\"",
"mydata.csv"
)
);
Watch letting users enter a value for this filename directly, though, since you're
writing it back out to the HTTP protocol's headers (a hacker could easily craft
a malformed header).
Derek Harmon