Concept: Anti-theft chain refers to the user does not go through our website direct access to our images we gave him a wrong picture processing principle: Gets the URL of the current and last request to the site domain name and port number comparison Returns the true picture if it is the same (if it is not possible to return true if it is linked from another site) The error picture procedure is returned: 1. Create a new generic handler to process 2, add httphandlers node information in webconfiguration
Public voidProcessRequest (HttpContext context) {context. Response.ContentType="Image/jpeg"; //Current requestUri URL =context. Request.url; //Last RequestUri referrer =context. Request.urlreferrer; if(Compareurl (url,referrer)) {//Legal//string path = context. Request.mappath (context. Request.rawurl);context. Response.WriteFile (URL. Absoluteuri); } Else { stringPath = context. Request.mappath ("daolian.jpg"); Context. Response.WriteFile (path); } } Private BOOLCompareurl (Uri U1, Uri U2) {returnUri.compare (U1, U2, Uricomponents.hostandport, uriformat.safeunescaped, Stringcomparison.currentcultureignorecase) ==0; }General Processing Files
<system.web> // full write in Type here the first argument is the namespace + class The second argument is the assembly name <add verb="*" type="fangdaolian" path= " images/*.jpg "/>
WebconfigGlobal picture anti-theft chain processing