Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Response.Addheader and Response.ContentType


Message #1 by "Daniel Fisher" <lennybacon@y...> on Tue, 13 Nov 2001 15:09:36 +0100
Hi,
I had about the same problem, but in my case, users can download any kind 
of file.
This is the way I did it: (and it works)

Response.ContentType = "";
Response.AddHeader("content-disposition","attachment; filename=" + 
strRealFileName);
Response.WriteFile(fn);


Where fn contains the name of the file on the server, and strRealFileName 
is the name suggested in the download dialog.


Bart Vanwesemael
bva@E...


> Hello
> 
> In asp i used this to force dowload-popup, but why doesn=B4t it work in
> aspx??
> 
> 
> <script language=3D"C#" runat=3D"Server">
> void Page_Load(object sender, EventArgs e) {
>   Response.Addheader("Content-Disposition", "attachment;
> filename=3Dtest.csv")
>   Response.ContentType =3D"text/csv";
>   Response.Write("1,test,45");
> }
> </script>
> 
> Daniel
> 
> 
> 
> _________________________________________________________
> 
> Do You Yahoo!?
> 
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> 

  Return to Index