For example: http:/www.jb51.net/8888/
The page is rewritten by http://www.jb51.net/ArticleShow.aspx?id=8888.
Specific implementation methods:
Use IIS's 404 error to implement
"HTTP 404-Files Not found" may be a mistake that you often see and dislike, but good use of this error can give
Web design brings good results, this article is the use of 404来 to achieve a new file.
Specific steps:
1. First set up a page, such as called error.aspx, placed in the root directory of the site, write key code in the Error.aspx
Copy Code code as follows:
public partial class Error:System.Web.UI.Page
{
String Myurl;
int MyPos;
int Myurllen;
String ID;
protected void Page_Load (object sender, EventArgs e)
{
Myurl = Request.Url.ToString ();
MyPos = Myurl.lastindexof ("/") +1;
Myurllen = Myurl.length;
if (MyPos = = Myurllen)
{
Myurl=myurl.remove (MYPOS-1);
MyPos = Myurl.lastindexof ("/") + 1;
Myurllen = Myurl.length;
}
id = myurl.substring (mypos, Myurllen-mypos);
The ID is out here, and the other operation is simple.
The following is based on the ID read the database information, I omitted ....
}
}
2. Modify IIS Custom error messages
Find 404, change the message type to Url,url address is "/error.aspx"
And then it's OK.
Other things to note: I'm not clear yet how efficient this is, compared to other rewrite software I'm not too clear,
Everyone can test and see. We also hope that you can propose a better solution.