How to Intercept the download of a Media file
Intercepting the download process of MediaData in Episerver can be helpful when e.g. tracking of downloads or lead generation features are requested by clients. Previously our Episerver teams has numerous times been requested to implement scenarios that ensures valuable visitor information are collected before a file-download is processed.
I won’t cover the actual generation or download tracking, but I will instead focus the interception of the download-process. It enables you to implement any customized logic that is tailored for the need of your solution.
Episerver does indicate how something like this can be achieved in their documentation. Multiple posts on Episerver World though tells me that it hasn’t been explained thoroughly enough. So I prepared a code-snippet that helps clarifying this topic.
It is important that Episerver is aware of the implementation. Implementing IRenderTemplate
Hopefully this small post provided you with the information you needed in order to intercept the download process in Episerver.