N
nino.altran
In an aspx page there is the possibility to download a file. I don't
want to give the user a direct link, so I wrote the following code:
.....
try
{
byte[] buff = System.IO.File.ReadAllBytes(path);
int filesize = buff.Length;
Response.ClearHeaders();
Response.AddHeader("Content-type", ContentType);
Response.AddHeader("Content-Disposition", "attachment;
filename=\"" + filename + "\"");
Response.OutputStream.Write(buff, 0, filesize);
Response.OutputStream.Flush();
}
catch
{ .....
I have a problem:
- If I put this code in my page, when the postback is executed the
download starts, but the page "dies" (the postback doesn't render
again my page)
- If I put this code in a new page, loaded in a popup, the download
starts but the popup "dies" (I can't write anything in it and I don't
know how I can close it automatically)
Can someone help me? Thank you in advance!
want to give the user a direct link, so I wrote the following code:
.....
try
{
byte[] buff = System.IO.File.ReadAllBytes(path);
int filesize = buff.Length;
Response.ClearHeaders();
Response.AddHeader("Content-type", ContentType);
Response.AddHeader("Content-Disposition", "attachment;
filename=\"" + filename + "\"");
Response.OutputStream.Write(buff, 0, filesize);
Response.OutputStream.Flush();
}
catch
{ .....
I have a problem:
- If I put this code in my page, when the postback is executed the
download starts, but the page "dies" (the postback doesn't render
again my page)
- If I put this code in a new page, loaded in a popup, the download
starts but the popup "dies" (I can't write anything in it and I don't
know how I can close it automatically)
Can someone help me? Thank you in advance!