H
hoenes1
I've got an aspx-Page "SendFile.aspx" which is called by a Link on
"ShowListOfFiles.aspx" and sends the file in the OnLoad Eventhandler.
The filename to download is stored in a Session variable. I'm sending
the file to the client in 4 KB chunks. Sending the file works fine,
but when I click a link on the calling aspx-Page
("ShowListOfFiles.aspx") after the download completed, the browser
window shows fragments of the recently transmitted file and a plain
text HTTP header. Looks like the Response buffer isn't cleared
correctly.
Here's the relevant code in "SendFile.aspx":
private void Page_Load(object sender, System.EventArgs e)
{
// prerequisites, e. g. open FileStream, ...
while (offset < size)
{
if (size-offset < bufSize)
bufSize = size-offset;
fs.Read(buf, 0, (int)bufSize);
Response.BinaryWrite(buf);
Response.Flush();
offset += bufSize;
}
fs.Close();
// I've tried Response.Close(), Response.End(),
Response.Clear(), ...
}
Anyone knows this issue and a solution or workaround?
Thanks in advance.
"ShowListOfFiles.aspx" and sends the file in the OnLoad Eventhandler.
The filename to download is stored in a Session variable. I'm sending
the file to the client in 4 KB chunks. Sending the file works fine,
but when I click a link on the calling aspx-Page
("ShowListOfFiles.aspx") after the download completed, the browser
window shows fragments of the recently transmitted file and a plain
text HTTP header. Looks like the Response buffer isn't cleared
correctly.
Here's the relevant code in "SendFile.aspx":
private void Page_Load(object sender, System.EventArgs e)
{
// prerequisites, e. g. open FileStream, ...
while (offset < size)
{
if (size-offset < bufSize)
bufSize = size-offset;
fs.Read(buf, 0, (int)bufSize);
Response.BinaryWrite(buf);
Response.Flush();
offset += bufSize;
}
fs.Close();
// I've tried Response.Close(), Response.End(),
Response.Clear(), ...
}
Anyone knows this issue and a solution or workaround?
Thanks in advance.