. Net implements URL rewriting and pseudo-static

Source: Internet
Author: User

. Net implements URL rewriting and pseudo-static

1. Obtain Mircosoft URLRewriter. dll:

Get Mircosoft URLRewriter. dll available to http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx? Mfr = true

 


After the download is complete, import the project. I have not made any changes to the project here, keep the original rewrite method, and then generate the. dll file directly in VS2005.
2. Use the dll file:
Add reference.
3. The page design is not described here. I will put a download package. If you are interested, please download it and check that the code is messy.
4. web. config Configuration
This is critical, and it is also the key to static-based success.

<? Xml version = "1.0"?>
<Configuration>
<ConfigSections>
<Section name = "RewriterConfig" type = "URLRewriter. Config. RewriterConfigSerializerSectionHandler, URLRewriter"/>
</ConfigSections>

<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor> ~ /Web/new/type/(. [0-9] *)/. html </LookFor>
<SendTo> ~ /Web/new. aspx? Id = $1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~ /Web/index.html </LookFor>
<SendTo> ~ /Web/index. aspx </SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<System. web>
<HttpHandlers>
<Add verb = "*" path = "*. aspx" type = "URLRewriter. RewriterFactoryHandler, URLRewriter"/>
<Add verb = "*" path = "*. html" type = "URLRewriter. RewriterFactoryHandler, URLRewriter"/>
</HttpHandlers>
<Compilation debug = "true"/> </system. web>
</Configuration>

Here is a brief introduction:

<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor> the mode to be searched </LookFor>
<SendTo> string used to replace the mode </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> the mode to be searched </LookFor>
<SendTo> string used to replace the mode </SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
HttpHandlers is mainly used in combination with IIS to redefine and process requests. This is also critical. If there is no reasonable httpHandlers, the access will certainly fail.

You can search for regular expressions in Baidu: "common regular expressions", there will be many.

5. Configure the iis .html File
Right-click my computer --> Manage --> Expand 'services and Applications' --> internet Information Service --> Find the directory you shared --> right-click Properties --> click 'configuration' --> under ing --> Find. aspx executable file path copy path --> paste path --> the extension is ". html "--> then remove the check object check box. If the" OK "button becomes invalid, you can use the keyboard event editing path to solve the problem.

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.