views:

47

answers:

2

I am planning to sell digital goods on my website (Asp.net). After successful payment the customer will be redirected to the download page of my website, which will display the link to download the digital content stored in my server.

I want to secure the location of the file, by creating a disposable link to the file. Every time a customer visits this page a new download link will be generated for the same file. Also this link should expire after it is downloaded for the first time.

Is it possible to do it in asp.net ( C# preferably )? if yes how can i do it?

A: 

Yes it is possible. One way would be to use handler (.ashx) files.

Ben Robinson
A: 

If you want to the Link itself and not the query string to expire you will need to us MVC or at the very least URL routing in .NET. Then you will need to do the following:

  1. Create a table with the expiring URL (generate with using time or GUID generator), createdate & time, and how long before it expires.
  2. When a user clicks the link it will check in the RouteHandler for a row existing in the table. If the row exists and the createdate & time + expiration time is still greater than current time then show them the page. Otherwise redirect them to whatever page you want.
RandomBen