RequestMember:
1.Request. urlrefererThe source of the request. Based on this, you can determine which keyword to search for from Baidu, anti-download leeching, anti-image leeching, and can be forged (such as thunder ).
2.Request. userhostaddressObtain the visitor'sIPAddress
3.Request. mappath (virtualpath ):Converts a virtual path to a physical path on the disk.
The idea of image anti-leech protection isURLInformation and the information requested by the current customerURLInformation, if the same domain name orIPAddress,
It means that the internal page of your website is applying for images on your website. In general processingProgramMedium, simpleCodeAs follows:
UriUri1 = context. Request. urlreferrer;
UriUri2 = context. Request. url;
If(URI. Compare (uri1, uri2, uricomponents. Hostandport, uriformat. Safeunescaped, stringcomparison. Ordinalignorecase )! = 0)
{
Context. response. Clear ();
Context. response. Close ();
}
Else
{
}
Response object Member
Response Buffer output: To improve server performance, ASP. NET does not write once to the browser by default.
Will be immediately output to the browser, but will cache the data, to the appropriate time or the end of the response can be sent together to the browser buffer data.
ResponseMain Member of the object:
Response. buffer, response, buffetoutput:The two are actually the same. They are used to control whether the response cache is used. The default value isTrue;
Response. Flush ()Send data in the buffer to the browser. This requiresWriteWhen the content is immediately output to the browser, it is very useful.
For example, we can use a small example to simulateResponse. Flush ()Effect:
In the general processing program:
Public void processrequest ( httpcontext context) {
context. response. contenttype = " text/html " ;
For(IntI = 0; I <20; I ++)
{
Context. response. Write (I );
Context. response. Flush ();
System. threading.Thread. Sleep (500);
}
}
When response. Flush is used, numbers are popped out one by one.
If not, the numbers are loaded in one breath.
Response. Clear ()Clear the data in the cache, so that the data that is not sent to the browser in the cache is cleared and not sent to the browser.
Response. contentencodingEncoding of the output stream.
Resoponse. contenttypeThe content type of the output stream. For exampleHTML (text/html)Or plain text (Text/plain)OrJPEGImage(Image/JPEG );
Response. outputstreamOutput stream, in the output image.ExcelFile and other non-text content should also be used.
Response. End ()Terminate the response and send the cached data to the browser,End ()Subsequent code will not be executed. In the anti-compiler,EndMethod calledFlush ()Method,
When terminating some illegal requestsEnd() Terminate the request.
ServerAttribute:
ServerAttribute isHttpserverhtilityAn instance that accesses methods and attributes on the server.
Server. mappath ():Obtain the physical path of a file
Server. ExecuteAndTransfer (): Execute the script for another page
Server. htmlencode ()AndHtmldecode ()Method: encode the text into a format that can be viewed correctly in the browser.
Server. urlencodeMethod andUrldecodeMethod:URLEncoding and decoding
Server. Tranfser ()AndResponseredirect ()Differences:
Server. Tranfser ()It is the internal takeover of the server (cannot be redirected to an external website),This redirection has nothing to do with the browser, and the address bar of the indexing browser will not change.
Response. Redirect ()Can be redirected to an external website