T
Tony K
I have the most peculiar problem with an ASP.NET page which we use for
downloading a file.
When the user clicks on a link, the link points to an ASPX page which
downloads the file selected.
The code works fine except after the user saves the file, the links on the
left side of the
frameset do not work. IE locks up.
If the user clicks the refresh button after they download, then everything
works properly again.
Or if the user selects 'OPEN' instead of 'SAVE' on the download dialog box
then the problem doesn't occur.
If I comment out the following line then the problem doesn't occur, however
the attachment name doesn't
appear in the download dialog box either.
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
There is something about the attachment name that is causing this problem.
The reason we do this in an aspx page instead of in a script is because we
want to do a server side
database update to record the user who is about to download the file (that
code is not shown below).
private void Page_Load(object sender, System.EventArgs e)
{
FileInfo fi = new FileInfo("C:\\test.aspx");
string filename = fi.Name;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
// "\"" + filename + "\"\""
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(filepath);
Response.End();
Response.Flush();
}
downloading a file.
When the user clicks on a link, the link points to an ASPX page which
downloads the file selected.
The code works fine except after the user saves the file, the links on the
left side of the
frameset do not work. IE locks up.
If the user clicks the refresh button after they download, then everything
works properly again.
Or if the user selects 'OPEN' instead of 'SAVE' on the download dialog box
then the problem doesn't occur.
If I comment out the following line then the problem doesn't occur, however
the attachment name doesn't
appear in the download dialog box either.
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
There is something about the attachment name that is causing this problem.
The reason we do this in an aspx page instead of in a script is because we
want to do a server side
database update to record the user who is about to download the file (that
code is not shown below).
private void Page_Load(object sender, System.EventArgs e)
{
FileInfo fi = new FileInfo("C:\\test.aspx");
string filename = fi.Name;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
// "\"" + filename + "\"\""
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(filepath);
Response.End();
Response.Flush();
}