Downloading files cause IE to lock up in ASPX page

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();
}
 
K

karl

by using a register script similar to this in your code then you can
actually use a script from your server.

this.RegisterStartupScript("popupDialog", "<script language='javascript'>
showAlertDialog(); </script>");

simply place it after the code that you need to fire first.


Karl
 
T

Tony K

I can't say I totally understand how registering a script would help in this
situation since I have server side database updates to do, to record history
of downloads, etc.

Maybe if you could expand on your example a little more so I would know
where the database updates would go and how to execute the script on the
server side that would help. If registering the script is an IE only
solution then we can't use it since we are trying to support Netscape 6.0
also.

I'd also like to know if this is a known bug in ASP.NET or a bug in IE.
Netscape doesn't have this problem.

Here is all the code if that helps.

private void Page_Load(object sender, System.EventArgs e)
{
UploadedFiles UPFiles = new UploadedFiles();
string filepath = Page.Request.Params["file"];
if (!(filepath == null))
{
HPSession HPSess = new HPSession();
string UserID = HPSess.getUserIDbySessionID(Session.SessionID);
UPFiles.UploadedFilesHistoryAddUpdate("",
Page.Request.Params["UploadedFileID"], UserID);
FileInfo fi = new FileInfo(filepath);
string filename = fi.Name;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
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();
}
}
 
T

Tony K

I tried executing the code from the link you provided. The code never gets
executed even when I click the "get PDF" button. I'm glad to know that
there may be problems with downloading PDF files, and that there is a fix
for it, but this is not the problem I am experiencing. The files download
just fine (they are text files).

However, after the user successfully downloads the files the hyperlinks in
the frameset do not work until the user clicks the refresh button.
 
T

Tony K

Okay, I finally got the server-side script to work. However, the problem
with IE breaking still remains.

This was a fun exercise. I now know how to execute code from a server side
script. The key was making sure not to reference the "code behind" in the
language statement.

In other words, do this:
<%@ Page Language="C#" %>

NOT this:

<%@ Page language="c#" Codebehind="FileDownload.aspx.cs"
AutoEventWireup="false" Inherits="HIPAAWeb.Upload.FileDownload" %>

So, now that this exercise has been completed. We need to get back to the
real problem. As stated in my first posting, this problem only occurs in IE
not Netscape. After downloading and SAVING the downloaded file, IE will not
load a page when you click on a hyperlink in the left side of a frameset.

Send me a note and I will give you a private link to our test web servers
where you can see the problem for yourself.

Thanks,

Tony Kurzendoerfer
 
J

Jacob Yang [MSFT]

Hi Tony,

I am very glad to know that the server-side script works now. Thank you for
sharing the information.

For the original question, please send the following to my email box
(e-mail address removed) :

1. The private link to show me the problem step by step

2. The related server side code for the downloading

I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top