473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Some IEs crash when using Response.WriteFile()

We are building a webapplication but keep hitting a wall: The user can
download files but we need to check if they are authorized to do so. We do
this with a download-page and use the following code:

public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.AppendHeader("Content-Disposition", "attachment;
filename=test.txt");
context.Response.AppendHeader("Content-Length", "4");
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile("c:\\test.txt");
context.ApplicationInstance.CompleteRequest();
}

The problem is that on some browsers (2 out 3 tested Windows 2000-machines,
1 out of 4 tested Windows XP-machines. All with IE6) just crash when the
download is finished. If we choose to open the file instead of saving it in
the download-dialog everything works fine and we're able to save the file to
disc from notepad. The test-machines are able to download files from other
webapplications.

We removed all code but the above. We did use a FileInfo-object to get the
length but to avoid all variables we hardcoded the file-length of test.txt.
We tried with an empty aspx-file and the above code in the codebehind-file.
Now we are using an IHttpHandler with the same code and same result.

We have tried to open the file and use Response.BinaryWrite with the same
result. We have tried to different combinations of the headers and leaving
one or both out. We have tried with Application/x-msdownload instead of
application/octet-stream.
We have tried using Response.End() instead of
ApplicationInstance.CompleteRequest();

Why is IE crashing? What can we do to avoid it? Has anyone else experienced
this problem?
Nov 22 '05 #1
1 4347
The code was running in an iframe. We changed the target to "_parent" and now
it all works. Seems to be some combination of an iframe-problem,
security-settings in the browser and maybe smartnavigation.

"Claus Pedersen" wrote:
We are building a webapplication but keep hitting a wall: The user can
download files but we need to check if they are authorized to do so. We do
this with a download-page and use the following code:

public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.AppendHeader("Content-Disposition", "attachment;
filename=test.txt");
context.Response.AppendHeader("Content-Length", "4");
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile("c:\\test.txt");
context.ApplicationInstance.CompleteRequest();
}

The problem is that on some browsers (2 out 3 tested Windows 2000-machines,
1 out of 4 tested Windows XP-machines. All with IE6) just crash when the
download is finished. If we choose to open the file instead of saving it in
the download-dialog everything works fine and we're able to save the file to
disc from notepad. The test-machines are able to download files from other
webapplications.

We removed all code but the above. We did use a FileInfo-object to get the
length but to avoid all variables we hardcoded the file-length of test.txt.
We tried with an empty aspx-file and the above code in the codebehind-file.
Now we are using an IHttpHandler with the same code and same result.

We have tried to open the file and use Response.BinaryWrite with the same
result. We have tried to different combinations of the headers and leaving
one or both out. We have tried with Application/x-msdownload instead of
application/octet-stream.
We have tried using Response.End() instead of
ApplicationInstance.CompleteRequest();

Why is IE crashing? What can we do to avoid it? Has anyone else experienced
this problem?

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Claus Pedersen | last post by:
We are building a webapplication but keep hitting a wall: The user can download files but we need to check if they are authorized to do so. We do this with a download-page and use the following...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
3
by: Anders | last post by:
Hi, This is the code I am using: string filepath = "Themes/img/logo.rar"; string filename = System.IO.Path.GetFileName(filepath); Response.Clear(); Response.ContentType = "application/zip";
2
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle...
4
by: JIM.H. | last post by:
Hello, I use this: Response.Redirect("/Files/myFile.xls") which is working fine but shows address bar and I am trying to get rid of it. So if I have the following, will this let me see excel...
4
by: david | last post by:
I has a question: I can use Response.WriteFile to display images such as .jpg. But I can not us it to display words doc file in EI by calling Response.WriteFile("testdoc/DownloadLarge.doc"). It...
1
by: Cindy H | last post by:
Hi I used the code below to automatically open a pdf file when the user clicks on a menu option. It works great on local machine, but when I uploaded it to hosting site and then tried it, I...
3
by: MatsL | last post by:
Hi, I'm having a problem sending a file using TransmitFile(). The code works perfectly using WriteFile() so I'm a little confused. Does TransmitFile() have any other prerequisites than...
12
by: benjamin.krulewitch | last post by:
I'm debugging an issue with a C program that causes the computer to crash, and I'm attempting to log information immediately before the crash occurs. I us my BKprintLog function (see below) to...
0
by: Nathan Sokalski | last post by:
I am using an *.aspx page with a querystring to access graphics that I am using in rollovers. I am using Response.ContentType and using Response.WriteFile(). This sends the graphic perfectly fine,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.