473,466 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Downloading file from database

I have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window. If the file is jpg, text, etc it appears in a seperate application
window. The desired behaviour is to always show the document in a seperate
window, but I can't write specific code to handle each file type
individually. Is it possible to force the file to download a view in a
seperate window?
Nov 24 '05 #1
4 1547
Just the correct content type.
I enforce downloading PDF instead of viewing it this way.
"Jeremy Chapman" <me@here.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window. If the file is jpg, text, etc it appears in a seperate
application window. The desired behaviour is to always show the document
in a seperate window, but I can't write specific code to handle each file
type individually. Is it possible to force the file to download a view
in a seperate window?

Nov 24 '05 #2
The type is correct. But for some types windows displays them using IE, and
in that case it displays it in the same window as the list of files. If
it's in IE, I want it to display in a seperate window.
"Edwin Knoppert" <in**@pbsoft.speedlinq.nl> wrote in message
news:dm**********@azure.qinip.net...
Just the correct content type.
I enforce downloading PDF instead of viewing it this way.
"Jeremy Chapman" <me@here.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window. If the file is jpg, text, etc it appears in a seperate
application window. The desired behaviour is to always show the document
in a seperate window, but I can't write specific code to handle each file
type individually. Is it possible to force the file to download a view
in a seperate window?


Nov 24 '05 #3
Oh, i meant it the other way around, by NOT using the real type like pdf but
that inary, you get the download fialog.
But now i see you don't want that.
You might consider to open an new window and point to the pdf.
But i don't think you'll be able to determine if the pdf get's loaded IN the
window or not.

So, leave it to the user..

"Jeremy Chapman" <me@here.com> schreef in bericht
news:%2****************@tk2msftngp13.phx.gbl...
The type is correct. But for some types windows displays them using IE,
and in that case it displays it in the same window as the list of files.
If it's in IE, I want it to display in a seperate window.
"Edwin Knoppert" <in**@pbsoft.speedlinq.nl> wrote in message
news:dm**********@azure.qinip.net...
Just the correct content type.
I enforce downloading PDF instead of viewing it this way.
"Jeremy Chapman" <me@here.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window. If the file is jpg, text, etc it appears in a seperate
application window. The desired behaviour is to always show the
document in a seperate window, but I can't write specific code to handle
each file type individually. Is it possible to force the file to
download a view in a seperate window?



Nov 24 '05 #4
Hi Jeremy

You just have to put your page stream code in a seperate file, and then link
to that file with window.open() or target="_blank", when everything should
work just like you want... ;)

/Stendal

"Jeremy Chapman" <me@here.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP14.phx.gbl...
I have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window. If the file is jpg, text, etc it appears in a seperate
application window. The desired behaviour is to always show the document
in a seperate window, but I can't write specific code to handle each file
type individually. Is it possible to force the file to download a view
in a seperate window?

Nov 25 '05 #5

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

Similar topics

6
by: Tony K | last post by:
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. ...
0
by: Sathya | last post by:
Hi Am using an ASP.NET website. i have an excel template stored in a folder in the server. the excel template already has some data inside. i need to add some more data to the excel sheet...
2
by: Matt Mercer | last post by:
Hi all, Well, thanks to some smart/helpful people here my upload and download section of my website works great! I am allowing users to upload directly into the SQL database but files cannot...
0
by: TJ | last post by:
Hi, I've written code web-based uploading and downloading. Here is some code for it. For saving file into MS-SQL database, SaveFileIntoDB(HttpPostedFile file) { int fileLength =...
4
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
0
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops...
2
by: Tomas Martinez | last post by:
Hi there! I'm trying to download a file in my asp.net web, but when downloading it from a Firefox browser, instead of downloading the example.exe file, it's downloading example.exe.htm. My code...
4
by: redoranda | last post by:
I have written a script for retrieving the records from the pgsql database then create a text file(records.txt) and save it on the server, after that attach that file in order to email to the...
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,...
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.