开发者

How to write the code for self expiring download link for asp.net website?

开发者 https://www.devze.com 2023-01-08 11:40 出处:网络
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

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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消