473,385 Members | 1,606 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,385 software developers and data experts.

using Response.Outputstream browser closes immediately

I have a c# web app on .net 1.1 framework. Currently I have a process where I can upload files (.doc, .xls, etc) to a my sql database. When trying to open the files however I'm running into an issue with IE7.

Basically I return the list of files and the id to a datagrid. When I click on the link to "open" the file, IE 7 opens a new window and then immediately closes the window. The process works fine if it's running on localhost, but when I move it to the webserver is where the problem happens. In straight html I would set the link target to "download" and everything would work fine. I'm not sure if there is an equivilent way of doing this with c#. Below is the code for downloading the file.

Expand|Select|Wrap|Line Numbers
  1. fitguru.dfDataAccess data = new fitguru.dfDataAccess();              
  2. int docnumber = 0;
  3. try
  4. {
  5. docnumber = int.Parse(Request.QueryString["dfPk"]);
  6. }
  7. catch(System.ArgumentNullException ee)
  8. {
  9. docnumber = 0;
  10. }
  11. int dfDocPk = (Convert.ToInt32(Request.QueryString["dfPk"]));
  12. byte []  buffer = data.getDoc(dfDocPk);
  13. System.IO.MemoryStream stream1 = new System.IO.MemoryStream(buffer,true);    
  14. stream1.Write(buffer,0,buffer.Length);
  15. if(docContent == "doc")
  16. {
  17. Response.ContentType = "application/msword";
  18. }
  19. else if(docContent == "xls")
  20. {
  21. Response.ContentType = "application/vnd.ms-excel";
  22. }
  23. Response.OutputStream.Write(buffer,0,buffer.Length);
  24. Response.End();
  25.  
any ideas how to resolve this? thanks
Apr 2 '08 #1
0 984

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jenny | last post by:
My application generates images dynamic. These images are then used for an image button like in the beneath. Dim ob As Bitmap = New Bitmap(130, 30) Dim banner As Graphics =...
2
by: 1 | last post by:
Hi there, A while back I wrote some code using the .Net drawing libraries... this code takes a datatable and generates a pie or bar chart on the fly. The resulting image is returned using...
0
by: ProJee | last post by:
Hi, Response.WriteFile (or Response.OutputStream.Write) finishes immediately, not after the file is completely downloaded. It finishes before (!) the user clicks the "Save" or "Open" browser...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
0
by: Dave | last post by:
Hi, I'm trying to download a pdf from a secure location and writ e the response to the browser as listed below. However, the form that runs this codes appears to postback when I encounter the...
3
by: André | last post by:
Hi, I want to include a graphic made in file2 into file. File must first send a value to file2 (with Response.Redirect) which will be used for the graphic. My problem is that only the graphic is...
3
by: T. Wintershoven | last post by:
Hi all, After a visitor has loged in, a session is started. The session is destroyed after the visitor clicked "Log out'. When the visitor forgets to log out and closes the browser...
4
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the...
13
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
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,...

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.