Global picture anti-theft chain processing

Source: Internet
Author: User

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 "/>      
Webconfig

Global picture anti-theft chain processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.