You can see a permanent link at the end of many blog log reading pages. This link is usually long-lasting. Even if the blog program is changed, you can use this link to access the original log without the problem of not being found. Page situation, this is indeed a practical function for a blog.
When modifying the blog program, I also considered this issue and decided to add a permanent link function to the blog log.
In IIS6, if a directory is requested followed by a parameter, this parameter will be passed to the default document. That is, if I request my blog homepage http://www.xujiwei.cn/blog/?id=500 , then id=500 will be Will be passed to the default document default.asp. You can use this to achieve permanent links to blog logs. Of course, this permanent link is established when the blog directory does not change. If the directory changes, additional processing will be required.
Response.Redirect can be used in ASP. The principle is that the server sends a 302 Object Moved response to the client, and then the client makes a redirection based on the response. However, this will increase additional bandwidth overhead and does not use search engines to include it, so it is recommended. Use Server.Transfer to redirect. Server.Transfer directly stops the execution of the current script and instead executes the specified script, and some current variables such as sessions can be used directly in the new script without having to re-pass parameters, while Response.Redirect Can't.
Another obvious difference between the two methods is that the URL displayed by the client will change when using Response.Redirect, but not when using Server.Transfer. When using Server.Transfer, the client will not feel that the current URL has actually changed. In fact, this difference can also be seen through the calling methods of the two methods. One is that Response.Redirect is changed by the client, while Server.Transfer is changed by the server.
After understanding these, you can start. Open the default document of the blog, which is usually the homepage of the blog program, such as default.asp, index.asp, etc., and then add the following code before the output content:
<%IF Request.QueryString ("id") Then Server.Transfer("article.asp")%>
Of course, article.asp needs to be changed accordingly according to the blog program. The id is the parameter to be used as a permanent link. It should be noted that this parameter must be recognized by article.asp, that is, article.asp can be based on this Parameters to display the log, if not, you need to make corresponding changes, that is, change the parameter name in article.asp to id, or change the id to another name.
OK, done! In fact, this thing is very simple. Such a long article is mostly nonsense, and the only thing that is really useful is a sentence of code.
Original text: http://www.xujiwei.cn/blog/?id=647