Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
I create ftp project or fileshare project to upload my files on ftp server then send email to the user to download this files in the link and i need to Prevent the user to use this link after specific time by code.
Posted
Updated 8-Jul-15 5:01am
v2

The whole idea behind ASP.NET, as well as all other server-side Web technology, is that you generate content in HTTP response dynamically, by processing HTTP request on the server side and doing required computations before sending the response. Essentially, this is all ASP.NET does.

This response can be anything, not only HTML. It can be any file generated dynamically. For example, if you deliver PNG file, its "Content-type" should be "image/png", which is one of HTTP headers. Instead of referencing the file directly in a <img> element in src attribute, you can reference ASP.NET page which code behind reads the file and writes it in HTTP response with proper headers. Please see: https://msdn.microsoft.com/en-us/library/System.Web.HttpResponse%28v=vs.110%29.aspx[^].

And then, in the middle, you check up the user's data, including authentication. You can store all the time stamps per each downloaded resources, compare with current time, and then decide if you want to deliver that file, or, instead appropriate response message explaining the problem, or even on of the error status codes 4??, (such as 417, see the last link below :-)).

See also:
https://en.wikipedia.org/wiki/Internet_media_type[^],
https://www.iana.org/assignments/media-types/media-types.xhtml[^],
https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Response_message[^],
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes[^].

—SA
 
Share this answer
 
There is no built-in way to do it. However, one way is to generate a timestamp and then encrypt it and put it into the querystring of the link. Then in your page that the link goes to, get the querystring value, decrypt it, and compare it to the system clock.
 
Share this answer
 
Comments
Member 10875212 9-Jul-15 6:45am    
thanks for your answer but i save this file in ftp server or folder and send the link to the user by Email so he can save the link to ftp or the folder direct not by Application
ZurdoDev 9-Jul-15 7:39am    
OK. Are you asking something?
thanks for your support but i have created two folders and create a function to move the files that uploaded by user to the second folder after certain period
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900