How can I generate a unique download link of a file on Asp.net api? I want to provide a download feature via webservice, each user just got a unique download link at a time.
UPDATE:
-
I dont want to waste time of user for login.
-
One user can download multiple file.
-
The file type can be xml, image, text and sound file.
I am trying to develop an application which sell ebook.
Thanks a lot
Can you give us more details what exactly you are trying to achieve.
any other scenario you can tell us?
It can be dont in many ways depending upon your scenario.
look for this example & will send you more
http://support.microsoft.com/kb/306654
One way of doing it if it fits your scenario
While you could use a GUID and maybe relate it to your user in your database, you would need to create some business logic around how that GUID is excepted by your application. For example you might say UserA has a GUID, if that GUID is used in the next 15 minutes let UserA log in automatically but after 15 minutes force the user to use a username and password.
Similarly you could make a query string, something like u=UserA&time=1347&date=01282001 and then run it through a hash of some sort. When it comes back in, unhash it (so you couldn’t use MD5), check the time stamp and see how long it has been since that timestamp was created. If it is within an acceptable time frame, let the user enter, if not force them to use a username and password. This would not require you to relate anything with your user in your database, so may be a more simple solution compared to a GUID.
Update: If i had to do it then i will take up following approach. It is up to you how you will protect these files from download.
Step 1: I will create a new table & generate a GUID once user make payment & store guid & userID, BookID information in this table. Now you can generate a link based on this information
Step 2: Create a HTTPHandler to check if such record is present in the table you created above if so then allow the user to download the book otherwise he should not be able to download the book.
You can keep all downloadable file under FOLDER which user dont have direct access.
I hope you understand what i am trying to say.
This is how i would do, I can either keep all files in protected folder or store them in DATABASE.
i hope this will give you a starting point.