Main CodeAs follows:
Copy codeThe Code is as follows: public void processrequest (httpcontext context)
{
Context. response. contenttype = "application/octet-stream ";
Httprequest Req = context. request;
String filename = Req. url. absolutepath;
String userid = string. empty;
If (httpcontext. Current. Request. Cookies! = NULL & httpcontext. Current. Request. Cookies ["userid"]! = NULL)
{
Userid = httpcontext. Current. Request. Cookies ["userid"]. value;
}
If (userid = "1 ")
{
String uuu = context. server. mappath (filename );
Context. response. transmitfile (uuu );
}
Else
{
String U2 = context. server. mappath ("default.rar ");
Context. response. writefile (U2 );
}
}
The design philosophy is as follows:
1. Use the ihttphandler interface to monitor whether the suffix of the resource request for this website is the file we want to block. If so, determine whether the file has the download permission. Returns a default useless file if no file exists.