Code0987
Code0987

Reputation: 2618

Preventing Users from Downloading file from website directly, how?

I need very advanced and effective method of Preventing Users from Downloading file from website directly in asp.net.

Method should -

limit downloads, limit time, limit requests, etc.

but should be downloadable by active login users

Upvotes: 1

Views: 528

Answers (3)

Carson63000
Carson63000

Reputation: 4232

Store the files in a folder which is not accessible via IIS (i.e., not underneath your web application's root)

Create an .ashx generic handler which takes a file identifier (either filename, or ID of some sort) as a QueryString parameter.

In that .ashx, perform whatever checks you want to perform: is the user logged in? have they downloaded too many files? etc.

Then, if you decide that they should be allowed to download it, set the response headers appropriately and write the file out to Response.OutputStream

Upvotes: 1

Hps
Hps

Reputation: 1177

You can put your files into a directory and configure that directory as not accessible by public users.

Upvotes: 2

Oded
Oded

Reputation: 499392

Delete the file from the server.

Any user trying to download it will not longer succeed.

Upvotes: 2

Related Questions