Click here to Skip to main content
11,714,776 members (77,528 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: IIS6 ASP.NET4.0
I have devloped a website and deploy it on IIS, then i have a create a window based application and trying to download some files from my deployed application. with the help of WebClient.dowonloadFile( and i can donwload that file.

So it is clear that my website is not secure, How to restrict files from being download. and if i want to download file then without help of credential it gives me error

how to accomplish my task.

Thanks in advnace
Posted 9-Jul-12 18:59pm
Sergey Alexandrovich Kryukov at 10-Jul-12 1:37am
Why do you consider downloading as "not secure"? How do you want to restrict downloads? And how come it can be a problem? You fully control how to respond to HTTP request...
Sergey Alexandrovich Kryukov at 10-Jul-12 1:40am
And, if you deploy it "on ISS" and this HTTP server is on some remote host, you cannot access it through Internet if its address is It could only be a local network address. Did you know that?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You did not explain how would you want to restrict the download, but most likely you would allow some downloads only for authenticated users. To learn about it, read this:[^].

Based on authentication, not only you can control the download, you can even restrict rendering the page from which one could download a file. Now, what about downloading itself?

With download, the simplest form is as simple as this:
<a href="">Download</a>
This is something you cannot "restrict". So, to provide restrictions, you need to use more complicated approach.

You can have some control to post a request for the file, for example, a button on a button click. The server part should generate HTTP response with the file. Note, that you don't even need a file in the file system on the server's host. The file is generated on the fly anyway. The correct "downloading" behavior of the client is directed by appropriate HTTP headers, in this case, this is "content-disposition". This is shown in the code sample of the answer to this question:[^].

Note, that this code sample also demonstrates some rudimentary restriction, by the requested file "extension". (See the string "File extension is not allowed" in the sample code.) Again, as this is your code, you impose the restrictions you want; this sample is enough for you to get the idea.


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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 Richard MacCutchan 275
2 Maciej Los 274
3 ManasKumarM 155
4 CHill60 135
0 Sergey Alexandrovich Kryukov 545
1 CHill60 375
2 Maciej Los 324
3 Richard MacCutchan 310
4 OriginalGriff 260

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100