Using Server.Transfer to implement rewrite simulation to generate static page effect in ASP

Source: Internet
Author: User

Before just understand 404.asp, once fantasy to write all the program code to 404.asp, to achieve a simulation to generate static Web site, if the program is small, with 404.asp to achieve rewrite or a good choice, if the program code up to 100000 lines, I am afraid to start climbing

Until I see the ASP's Server.Transfer, with 404 simulation to generate static page of the idea of the station in my mind again, now even in the large program, can also use the Server.Transfer of ASP easy to handle

<!--#include file="bin/404_Query"-->
< %
select case bin_command
case "bin"
server.transfer("bin/web")
case "uploadfiles"
server.transfer("bin/send-stream")
case else
server.transfer("bin/send-404")
end select
%>

Oh, frankly speaking, is based on Bin_command to determine the implementation of a very good function, if the bin is the Server.Transfer of the ASP transferred to the Bin/web, and then return the results, and can be a good solution to the friendly URL address problems, The effect of the implementation pattern to generate a static page. There is no rewrite in PHP, if you want to URL-friendliness is usually practical path_info, and this program by the ASP Server.Transfer simulation of the Path_info in PHP, the only need is to support 404.asp

Bin/404_query's source code is as follows:

< %
Urls=mid(request.querystring,instr(request.querystring,":80")+4)
if instr(Urls,"/")>0 then
bin_command=left(Urls,instr(Urls,"/")-1)
getfile=replace(Urls,bin_command&"/","")
else
bin_command="bin"
end if
%>

This code is mainly to determine bin_command by what to perform, first see if there is a level two directory, if there is no level two directory, then assign "Bin" (Representative program)

such as: demo.com/index5.html, then bin_command= "Bin", through the above code can be known to bin/web processing

Demo.com/uploadfiles/123456.gif (this file is actually corresponding to the files/123456.gif), then bin_command= "Uploadfiles", through the above code can be known to the bin/ Send-stream processing, send-stream How to output files/123456.gif it. I can refer to an article I wrote before ASP practical binarywrite and ADODB.stream implementation Download (http://miaoqiyuan.cn/p/asp-binarywrite-adodb-stream/)

demo.com/111/222, then bin_command= "111″, not defined in the Select Case, is else, to the bin/send-404 processing, the output did not find the file information

In this way all visitors (including: Baidu, Google) view, this site is a static generation of the page. As far as I know 99.9% of the domestic IIS host does not support Isapi_rewrite, it was once encountered, because the resource is too serious to be canceled soon.

Here is what I see on the ASP learning online, attached to the following for reference:

Call the Server.Transfer method, immediately terminate execution of the first page and start the second page.

If the first page starts writing to the response buffer, the second page appends the content to the buffer instead of replacing it.

If the buffer is turned on, the method modifies the HTTP header unless no content has been sent. If ASP buffering is off, HTTP headers will not be modified.

When transferred to another application, the Start page application and the Session object will contain the application information.

Related Article

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.