473,386 Members | 1,823 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,386 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 4345
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.