473,397 Members | 2,099 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,397 software developers and data experts.

Force Download Part 2

tma
Short of zipping my file, are there any other alternatives to the below?

I'm trying to add anchors in code and I need the link to force a download of
the .pdf rather than open a new window or worse, open the file in the
current client browser window. Is there something I can change about the
anchor itself to force this behavior? I did not have any success with the
"content-disposition" articles suggested.

Here is my very normal anchor code:

a = New HtmlAnchor

a.HRef = "http://www.someURL/Registration.pdf"

a.InnerText = "Print Application"

a.Target = "_blank"
Nov 18 '05 #1
4 1682
As long as you are linking directly to the pdf file on your webserver, the webserver (most likely) is going to send the HTTP headers in a way so your browser will attempt to open it up. To avoid this, you are going to have to create your own download page, which sets the headers you need to show the "save as" box, and then stream the file from your webserver to the client. Then your href in the hyperlink will look something like this

a.href="http://www.someurl.com/download.aspx?file=registration.pdf"

If you mentioned you were looking at articles about "content-disposition", you'll have to use this in the download page.

--Michael

"tma" <tm*@allisconfusing.net> wrote in message news:u7**************@TK2MSFTNGP09.phx.gbl...
Short of zipping my file, are there any other alternatives to the below?

I'm trying to add anchors in code and I need the link to force a download of
the .pdf rather than open a new window or worse, open the file in the
current client browser window. Is there something I can change about the
anchor itself to force this behavior? I did not have any success with the
"content-disposition" articles suggested.

Here is my very normal anchor code:

a = New HtmlAnchor

a.HRef = "http://www.someURL/Registration.pdf"

a.InnerText = "Print Application"

a.Target = "_blank"

Nov 18 '05 #2
if you never want pdf's to display from this site, you can update the server
mime type mapping for the vdir. a good solution would to create a seperate
vdir under your main vdir (say called download), that you update the mime
mappings, and a another vdir (using the same dir, say called display) that
has the standard mapping. then

mysite/download/mypdf.pdf

will use the save as, while

mysite/display/mypdf.pdf

will load in the browser

-- bruce (sqlwork.com)
"Raterus" <mo*********@suretar.reverse> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
As long as you are linking directly to the pdf file on your webserver, the
webserver (most likely) is going to send the HTTP headers in a way so your
browser will attempt to open it up. To avoid this, you are going to have to
create your own download page, which sets the headers you need to show the
"save as" box, and then stream the file from your webserver to the client.
Then your href in the hyperlink will look something like this

a.href="http://www.someurl.com/download.aspx?file=registration.pdf"

If you mentioned you were looking at articles about "content-disposition",
you'll have to use this in the download page.

--Michael

"tma" <tm*@allisconfusing.net> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
Short of zipping my file, are there any other alternatives to the below?

I'm trying to add anchors in code and I need the link to force a download of the .pdf rather than open a new window or worse, open the file in the
current client browser window. Is there something I can change about the
anchor itself to force this behavior? I did not have any success with the
"content-disposition" articles suggested.

Here is my very normal anchor code:

a = New HtmlAnchor

a.HRef = "http://www.someURL/Registration.pdf"

a.InnerText = "Print Application"

a.Target = "_blank"

Nov 18 '05 #3
tma
Can you point me in a direction for how to go about updating the MIME types
for that vdir where I want download only?

"bruce barker" <no***********@safeco.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
if you never want pdf's to display from this site, you can update the server mime type mapping for the vdir. a good solution would to create a seperate
vdir under your main vdir (say called download), that you update the mime
mappings, and a another vdir (using the same dir, say called display) that
has the standard mapping. then

mysite/download/mypdf.pdf

will use the save as, while

mysite/display/mypdf.pdf

will load in the browser

-- bruce (sqlwork.com)
"Raterus" <mo*********@suretar.reverse> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
As long as you are linking directly to the pdf file on your webserver, the
webserver (most likely) is going to send the HTTP headers in a way so your
browser will attempt to open it up. To avoid this, you are going to have to create your own download page, which sets the headers you need to show the
"save as" box, and then stream the file from your webserver to the client.
Then your href in the hyperlink will look something like this

a.href="http://www.someurl.com/download.aspx?file=registration.pdf"

If you mentioned you were looking at articles about "content-disposition",
you'll have to use this in the download page.

--Michael

"tma" <tm*@allisconfusing.net> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
Short of zipping my file, are there any other alternatives to the below?

I'm trying to add anchors in code and I need the link to force a download
of
the .pdf rather than open a new window or worse, open the file in the
current client browser window. Is there something I can change about the
anchor itself to force this behavior? I did not have any success with

the "content-disposition" articles suggested.

Here is my very normal anchor code:

a = New HtmlAnchor

a.HRef = "http://www.someURL/Registration.pdf"

a.InnerText = "Print Application"

a.Target = "_blank"


Nov 18 '05 #4
http://support.microsoft.com/default...Product=aspnet

"tma" wrote:
Can you point me in a direction for how to go about updating the MIME types
for that vdir where I want download only?

"bruce barker" <no***********@safeco.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
if you never want pdf's to display from this site, you can update the

server
mime type mapping for the vdir. a good solution would to create a seperate
vdir under your main vdir (say called download), that you update the mime
mappings, and a another vdir (using the same dir, say called display) that
has the standard mapping. then

mysite/download/mypdf.pdf

will use the save as, while

mysite/display/mypdf.pdf

will load in the browser

-- bruce (sqlwork.com)
"Raterus" <mo*********@suretar.reverse> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
As long as you are linking directly to the pdf file on your webserver, the
webserver (most likely) is going to send the HTTP headers in a way so your
browser will attempt to open it up. To avoid this, you are going to have

to
create your own download page, which sets the headers you need to show the
"save as" box, and then stream the file from your webserver to the client.
Then your href in the hyperlink will look something like this

a.href="http://www.someurl.com/download.aspx?file=registration.pdf"

If you mentioned you were looking at articles about "content-disposition",
you'll have to use this in the download page.

--Michael

"tma" <tm*@allisconfusing.net> wrote in message
news:u7**************@TK2MSFTNGP09.phx.gbl...
Short of zipping my file, are there any other alternatives to the below?

I'm trying to add anchors in code and I need the link to force a download
of
the .pdf rather than open a new window or worse, open the file in the
current client browser window. Is there something I can change about the
anchor itself to force this behavior? I did not have any success with

the "content-disposition" articles suggested.

Here is my very normal anchor code:

a = New HtmlAnchor

a.HRef = "http://www.someURL/Registration.pdf"

a.InnerText = "Print Application"

a.Target = "_blank"



Nov 18 '05 #5

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

Similar topics

2
by: Matthew Sims | last post by:
Is it possible to force a download without using the readfile function? My website setup consists of my server that serves the web pages plus a high-speed file server elsewhere on the internet...
2
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect...
4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
1
by: tma | last post by:
I'm trying to add anchors in code and I need the link to force a download of the .pdf rather than open a new window or worse, open the file in the current client browser window. Is there something...
0
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button,...
2
by: comp.lang.php | last post by:
class ReportGenerator { function ReportGenerator() {} /** * Generate the HTTP headers necessary for this file type. Can be called statically *
3
by: Bouffa | last post by:
Hello everyone, I suppose you all know force-download scripts. The problem is that these scripts don't allow files to be splitted when downloading them via a download manager. I've found a...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
0
by: savajx1 | last post by:
I am loading signed assemblies from a network share. The assemblies are NOT INSTALLED in the GAC as they are part of an enterprise distributed application implemented as a windows service that...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.