ASP. NET websites use Chinese URLs under pseudo-static conditions, asp.net

Source: Internet
Author: User

ASP. NET websites use Chinese URLs under pseudo-static conditions, asp.net

First, what is a Chinese URL? It is not a common way to encode Chinese characters as % CF % EC, but to directly use Chinese Characters in URLs.

 

This form is not widely seen at present. Different browsers may have different processing methods, but according to my tests, IE8 and Firefox are fully supported.

 

The advantage is that the link address can be easily understood! Search engines are also supported.

 

First, let's talk about the pseudo-static state of my asp.netwebsite. All my files end with .htm and are actually dynamic ASP. The method is to map htm to An aspx file in the background.

Pseudo-static rules are defined in the web. config file.

Form 1:

Http://www.huochebar.com/beijing.htm

Pseudo static code

<Rules>
<RewriterRule>
<LookFor> ~ /([^ Province/city to] +) [province/City] \. htm </LookFor>
<SendTo>
<! [CDATA [~ /Prov. aspx? Provname = $1]>
</SendTo>
</RewriterRule>
</Rules>

Form 2:

Http://www.huochebar.com/hubei /hankou .htm

<Rules>
<RewriterRule>
<LookFor> ~ /([^/] +)/(\ W +) \. htm </LookFor>
<SendTo>
<! [CDATA [~ /City. aspx? Provname = $1 & cityname = $2]>
</SendTo>
</RewriterRule>
</Rules>

The actual code processing is implemented in the background files prov. aspx and city. aspx, but the pseudo-static state completely hides this point.


What is the List link of aspnet pseudo-static url rewrite?

Modify the program. The program list is written as an HTML address.

Implement pseudo-static aspnet website pages

1. Find a file named UrlRewriter. dll on the Internet and put it in the bin folder of the item directory.
2. Configure web. config
(1) Add <section name = "CustomConfiguration" type = "URLRewriter. Config. UrlsSection, URLRewriter"/>
(2) add <add type = "URLRewriter. RewriterModule, URLRewriter" name = "RewriterModule"/> to the httpModules tab.
(3) add in the configuration tag
<CustomConfiguration>
<Urls>

<Add virtualUrl = "~ /News (. [0-9] *) \. html "destinationUrl = "~ /Article. aspx? Id = $1 "/>
<Add virtualUrl = "~ /Newsddd (. +) "destinationUrl = "~ /News. aspx? Id = $1 "/>
<Add virtualUrl = "~ /List (. [0-9] *) "destinationUrl = "~ /List. aspx? Id = $1 "/>
<Add virtualUrl = "~ /Admin/Login "destinationUrl = "~ /Admin/Login. aspx "/>
<Add virtualUrl = "~ /Search "destinationUrl = "~ /Search. aspx "/>
</Urls>
</CustomConfiguration>

These are Rewrite Rules

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.