There are many advantages of URL rewriting: article. aspx? Id = 1 can be rewritten to a1.aspx, which is easy to remember and advantageous to search engines. Currently, there are many URL rewriting methods in Asp.net. The simplest method is described below.
First, add the <configuration> </configuration> node in Web. config.
<Rewriterconfig>
<Rules>
<Rewriterrule>
<Lookfor> A (\ D {1, 5}) \. aspx </lookfor>
<Sendto> Article. aspx? Id = $1 </sendto>
</Rewriterrule>
<Rewriterrule>
<Lookfor> C (\ D +) \. aspx </lookfor>
<Sendto> column. aspx? Id = $1 </sendto>
</Rewriterrule>
</Rules>
</Rewriterconfig>
These CodeThe code above indicates that the rewrite rule is to set article. aspx? Id = 1 to a1.aspx? You can change the id = 1 to c1.aspx. Actually, it is to rewrite the a1.aspx address you requested from the server to article. aspx? Id = 1. In fact, the returned page is article. aspx? Id = 1
Next, add
<Httpmodules>
<Add type = "urlrewriter. modulerewriter, urlrewriter" name = "modulerewriter"/>
</Httpmodules>
That is to say, the page requested by the user to the server is handled by modulerewriter.
The last step is to put urlrewriter. dll (which is downloaded below) into the application. ProgramThe bin folder is OK.
In this way, you can enter [url = http: // *****/a2.aspx] HTTP in the browser: // *****/a2.aspx [/url] access is actually [url = http: // *****/article. aspx? Id = 2] http: // *****/Article. aspx? Id = 2 [/url.
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