Wednesday, January 04, 2006

ASP.Net allows you to manipulate the header of a Response object, so you can set the return type, define the file name, stuff like that. Here's a C# code snippet that does that, and forces the 'download file' dialog box to pop up, at least in IE.


String data = "blah, blah, blah!";

Response.AddHeader("Content-Type", "text/dat");
Response.AddHeader("Content-disposition", "attachment; filename=Export.dat");

Response.Write(data);


This has proved to be useful for the WebFIRS project, and will probably be needed in the future.

0 Comments:

Post a Comment

<< Home