Dynamic Download Link Using Hash Expiration


I want to ask what is the best way to have the link to a file expire after a set time, so that the user gets sent a download link via email which they only have access to for say 24 hours. I would prefer to use a hash tag instead of a web.config global setting or cookie. So that the system sends you a new hash like:

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why not just do it the way you suggested?  Just take the current time to ticks then use a basic hash such as base64 to create a somewhat obscured url.  Someone could reverse engineer it if they wanted but this method would be easy if the information wasn't very sensitive.

Sorry, I posted to a wrong question. Please ignore it.
Generate a random unique ID using System.Guid and store it  with time generated in database or XML file.

Write an IHttpHandler  which accepts the Guid as query string. Also check the expiry time of the Guid in the HttpHandler and use Response.TransmitFile  to write the specified file directly to the HTTP response if Guid is not expired.

Check the following links.

Create temporary file and auto removed

Creating public temporary files with expiration time

Dynamic download link algorithm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.