asp.net file downloading - track downloaded size

后端 未结 5 1643
半阙折子戏
半阙折子戏 2021-01-12 08:02

I am trying to design a system for something like this with ASP.net/C#.

The users pay for downloading some content (files- mp3s/PDFs,doc etc).I should be able to tra

5条回答
  •  感动是毒
    2021-01-12 08:59

    To do custom byte serving like this, you will need to implement your own http handler.

    This handler should do the following:

    • Implement some kind of authentication on the http handler, so you know who you are dealing with.
    • Then you will need to implement some kind of logging for files requested and files allowed to be downloaded.
    • Implement etags and expires headers for client side caching.
    • Server side caching
    • Deflate, gzip compression
    • If you want to support resumable downloads, you will need to implement 206 partial responses. This is essential for any kind of streaming and serving pdfs.

    So you should be handling the following http headers:

    • ETag
    • Expires

    • Accept-Ranges

    • Range
    • If-Range

    • Last-Modified

    • If-Match
    • If-None-Match
    • If-Modified-Since
    • If-Unmodified-Since
    • Unless-Modified-Since

    If you are looking for a sample implementations of http handlers check out: http://code.google.com/p/talifun-web/wiki

    It has a static file handler that implements all the above http headers, client side and server side caching and even compression.

    There is also a log module and an authorization module that should go a long way into how to implement authentication and logging.

提交回复
热议问题