Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
what do i do to allow a client to download a file from my website?
Posted
Comments
Sergey Alexandrovich Kryukov 12-Nov-12 23:31pm    
All resources you put in your site are downloadable. You don't need to do anything to allow that, unless you need some extra functionality.

If you are talking about ASP.NET, tag it.
--SA

Once you provide a link to your file in the web page, the client browser will take care of the download.
Try File Download in ASP.NET and Tracking the Status of Success/Failure of Download[^].
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Nov-12 23:33pm    
That is useful link, my 5, but I think main answer to the question is in my comment to the question, please see. I looks like OP does not clearly understand how Web works, even at the level of the Web browser user...
--SA
Member 9445358 12-Nov-12 23:47pm    
who is OP?
Sergey Alexandrovich Kryukov 13-Nov-12 0:13am    
Sorry... it means the author of the Original Post -- you, in this case...
--SA
Member 9445358 12-Nov-12 23:46pm    
When i try to link to file i get a 403 error(not allowed)
Sergey Alexandrovich Kryukov 13-Nov-12 0:13am    
Not clear what did you do, exactly.
--SA
With some file types, the web server (IIS) does not know what to do or blocks their download for security reasons (.mdb). The easiest solution is to zip the files which are to be downloaded - the extension .zip is normally registered. Otherwise you may need to register a new file type with IIS.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Nov-12 9:53am    
A good advice, by the way. My 5. But if you look at comments to Solution 1, you will probably see that OP is not yet there -- it's still about understanding how Web works... :-)
--SA
Bernhard Hiller 14-Nov-12 2:46am    
Thanks.
Many people do not give enough information to distinguish between a general failure (cannot download any file) and a specific failure (cannot download a specific file/file type). And when it comes to some distribution between server and client (Web, RDP, Citrix,...), even many experienced people fail to see on which side the problem originates.
Sergey Alexandrovich Kryukov 14-Nov-12 11:34am    
Agree; only your word "experienced" in this context looks questionable. If by "experienced" you mean "having long-time experience", then yes -- some people fail to understand what they do during lifetime of experience; I met an old person with most amazing lack if understanding and inability to make things work properly in 2008, will never forget the frustration. I just don't call such people "experienced".
--SA
Member 9445358 19-Nov-12 20:44pm    
It turns out there are special restrictions on the App_Data folder, and that is why it wouldn't download!
Sergey Alexandrovich Kryukov 19-Nov-12 21:22pm    
Makes no sense, really. If a user see the anchor, its different resource, it can be downloaded.

And please, don't put your comments as "solutions". "Add your solution here" is reserved only for the cases when you provide some help in response to some question. If it is not, it will be removed, but, worse for you, many members would down-vote it and even report you for abuse, which you don't want, so I removed that post.

--SA
I don't understand your concern, but most likely you just don't understand some very basic things. If you want the user to download some file, you can simply write:

HTML
<a href="somefile.pdf'>Some PDF document</a>


On anchor click, if the client has PDF support embedded in browser or available as plug-in, it will be loaded in the page, otherwise the user will get a choice do download it or open with some viewer, default or by the user's choice; in all cases, the user can simply download the file, as always with the anchor. With other file types (very typically, *.zip), the only option will be downloading. This code assumes that you place the file in the same directory as the present page, but it can be any directory relative to this page. Avoid using absolute paths, or use just the full URL, starting with the scheme.

Sorry if this is too trivial and you already know all that, but it actually answers your question. If you need some extra downloading features, ask about them specifically. But better start from here and hopefully you will be able to learn advanced things later.

As to your question on your error 403, please see the answer in my comment, in the discussions of the Solution 1.

On this problem, see also:
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx[^],
http://msdn.microsoft.com/en-us/library/ms524632%28v=vs.90%29.aspx[^].

Are you getting the idea? Normally, the applications are executed under HTTP server in a sandboxed environment which exclude the access to any directories outside the root directory mapped to the site.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900