Use Mircosoft URLRewriter. dll to implement pseudo-static page

Source: Internet
Author: User
Yesterday, I posted an article about using ISAPI filter to implement URL pseudo-static. I did it according to the content in the article, but it was not made. Currently, Microsoft URLRewriter is not used for this method. the dll method is good. At least I personally think it took me a night to finally find out how to use this dll file to implement static on the asp.net page, which is actually very simple.
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
Here, select [download the source code of this article]. After the download is complete, import the project. I have not made any changes to this project, and keep the original rewrite method, then it is generated directly in VS2005. dll file.
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.

Instance download: http://files.cnblogs.com/zhangyi85/StaticWeb.rar

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.