To implement file download statistics in IIS 6, I only know two methods:
1. Write your own ISAPI filters.
2. Map all files to ASP. NET runtime through wildcard ing, and then in ASP. NETProgramStatistics on the number of downloads, but also process file downloads.
In IIS 7, this function is easy to implement:
Write an httpmodule:
Using System;
Using System. Web;
Namespace Cnblogs
{
/// <Summary>
/// Summary Description for downloadcountmodule
/// </Summary>
Public Class Downloadcountermodule: ihttpmodule
{
Public Downloadcountermodule ()
{
}
# RegionIhttpmodule members
Public VoidDispose ()
{
}
Public VoidInit (httpapplication context)
{
Context. presendrequestcontent+ = NewEventhandler (context_prerequesthandlerexecute );
}
Void Context_prerequesthandlerexecute ( Object Sender, eventargs E)
{
Httpapplication app = (Httpapplication) sender;
Httpcontext Context = App. context;
String URL = Context. Request. rawurl;
// File Download statisticsCode
}
# Endregion
}
}
Then add the module (add managed module) to the modules in IIS 7.