how to setup a download page

  • Thread starter Thread starter Jeff Jarrell
  • Start date Start date
J

Jeff Jarrell

I want to setup a downloads page on my site. Most of the time they are zip
files but they are also MSI files. Things work ok if I simply put an <a>
element referencing the file to download but I'd like a little more smarts
to it. I'd like to know how many times the file was downloaded along with
the referrer information. I'd also like to hide the actual physical file
location.

So I send it to another URL to record the download but then how do I
initiate the download (from a push point of view).

thanks.
 
Try writing a custom HttpHandler. The parameters will usually be passed via
query strings. The custom handler then generates the appropriate ContentType
for the output, and generates the output data (eg. by reading the
appropriate file).

I am using this technique not for a file download but for a similar
purpose - a report generator page that contructs a report based on
parameters supplied to it, then supplies the report back as either HTML
output or PDF output.

You can also "get away with" using a standard ASP.NET form and using
Response.Write/Response.WriteFile and Response.End, but it is not a clean
solution.
 
I'd suggest creating a download page that manages such files. It might use
Response.WriteFile for example:

Response.Clear()
Response.ContentType = Whatever
Response.Writefile("c:\whatever.zip")
Response.AddHeader("Content-Disposition", _
"attachment;filename=whatever.zip")
Response.End()

Or you might choose to store your files in SQL Server, such as in this
example that explains all about uploading and downloading files:
http://SteveOrr.net/articles/EasyUploads.aspx
 
excellent. thanks.

Steve C. Orr said:
I'd suggest creating a download page that manages such files. It might
use Response.WriteFile for example:

Response.Clear()
Response.ContentType = Whatever
Response.Writefile("c:\whatever.zip")
Response.AddHeader("Content-Disposition", _
"attachment;filename=whatever.zip")
Response.End()

Or you might choose to store your files in SQL Server, such as in this
example that explains all about uploading and downloading files:
http://SteveOrr.net/articles/EasyUploads.aspx
 
Back
Top