Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2008, 12:14 PM
Authorized User
 
Join Date: Sep 2006
Location: Lenexa, KS, USA.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Downloading files from website to user's PC

Hi all,

I can't find any examples anywhere for how to download a file from my company's website to a user's PC. There'll be a gridview showing a list of (PDF) documents, with a linkbutton on each row, and when the user clicks on the linkbutton, I want it to open the download dialog so the user can browse to their desired folder and click download. (When I looked for this about 4-5 months ago, I couldn't find anything then either, and even found one comment that it wasn't possible.) Does anybody know how to do this? Thanks very much in advance for any help or advice.

-- LenexaKS


  #2 (permalink)  
Old February 15th, 2008, 12:27 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

PDF's, by default, will open in the browser and, as far as I know, there is no way to pragmatically override these settings so that the user is prompated with a file download as oppsed to the pdf opening in the browser.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #3 (permalink)  
Old February 15th, 2008, 12:39 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

You can certainly do it, and it's pretty easy to do. Here's quick example:
Code:
string fileName = "Test.pdf";
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/x-unknown";
Response.WriteFile(Server.MapPath(fileName));
Searching for stream file asp.net on Google should give you more results / ideas.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
  #4 (permalink)  
Old February 15th, 2008, 12:41 PM
Authorized User
 
Join Date: Sep 2006
Location: Lenexa, KS, USA.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks DParsons... I suspected that was the case.

  #5 (permalink)  
Old February 15th, 2008, 12:44 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ya, I learned something today! Thats why Imar gets paid the big buck ;]

Good stuff.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #6 (permalink)  
Old February 15th, 2008, 12:53 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Big buck??

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
  #7 (permalink)  
Old February 15th, 2008, 01:06 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Big bucks == big money. My mistake. =]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #8 (permalink)  
Old February 15th, 2008, 01:08 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I understand that. I was just wondering where the big money was coming from.

Or do you get paid for P2P posts?? ;)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
  #9 (permalink)  
Old February 15th, 2008, 01:17 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Haha, only in a perfect world would we get paid to post here but maybe Jim can squeeze that into his budget for next year ;]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
  #10 (permalink)  
Old February 15th, 2008, 02:51 PM
Authorized User
 
Join Date: Sep 2006
Location: Lenexa, KS, USA.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar, works like a charm!
(BTW, dparsons said "big BUCK", not "big buckS". But good karma from saving an ignorant coder is its own reward.)

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Website with Pocket PC Dlls ashu_from_india .NET Framework 2.0 3 June 11th, 2008 11:06 AM
downloading image from website pandjie Java Basics 1 December 11th, 2006 10:39 PM
Downloading files via a browser gfrank1157 ASP.NET 2.0 Basics 3 June 14th, 2006 04:13 PM
linked table on user's pc Spaceman Spiff Access VBA 8 March 11th, 2004 02:51 PM
downloading files serge Classic ASP Professional 4 September 8th, 2003 10:36 AM



All times are GMT -4. The time now is 07:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.