By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

Force Download Part 2

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.